Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8671747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:01:31+00:00 2026-06-12T19:01:31+00:00

So i have genereated a number from a count in #table1 which I want

  • 0

So i have genereated a number from a count in #table1 which I want to show in another table that I have created.
So the syntax for the first count is

select COUNT(*)
into #table1
from #test8
where account_number1 is null
GROUP BY varmonth,MONYEAR
ORDER BY varmonth, MONYEAR

Then the second table is

SELECT MONYEAR, 
COUNT(*) AS TOTAL,
SUM(CURRENT_BALANCE_AMOUNT) REH_BAL,
FROM #table1
WHERE ROWNUMBER = 1 
GROUP BY varmonth,MONYEAR
ORDER BY varmonth, MONYEAR

However I want that first count to slide in between the count and sum in the second table.
is there a way of doing this so all the numbers output in one final table?
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:01:32+00:00Added an answer on June 12, 2026 at 7:01 pm

    You can do this:

    SELECT
      t2.MONYEAR,
      t2.Total,
      t1.tcount,
      t2.REH_BAL
    FROM
    (
      select varmonth, MONYEAR, COUNT(*) tcount
      from #test8
      where account_number1 is null 
      GROUP BY varmonth,MONYEAR
    ) t1
    INNER JOIN
    (
      SELECT MONYEAR, 
        COUNT(*) AS TOTAL,
        SUM(CURRENT_BALANCE_AMOUNT) REH_BAL,
      FROM #table1
      WHERE ROWNUMBER = 1 
      GROUP BY varmonth,MONYEAR
    ) t2 ON t1.MONYEAR = t2.MONYEAR
    ORDER BY t1.varmontth, t2.MONYEAR
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this query which displays some properties and count the number of references
I have the following SVG source code that generates a number of boxes with
I have a function that generates normal random number matrix having normal distribution using
I have a loop in razor which generates a template a number of times.
I have a table with 3 columns which looks like this: File User Rating
I have a loop that takes values from textboxes and dropdowns and uses them
I'd like to know if it's possible to generate a SELECT COUNT(*) FROM TABLE
I have a table I am trying to generate reports from. Its basically a
Im trying to count the number of rows in the table and generate random
I have an ASP.NET GridView which is populated from a SQL Server database. This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.