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 7749517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:04:08+00:00 2026-06-01T11:04:08+00:00

I have a small sql question for you. I have two queries: SELECT tbl_CostPrevisions.Month,

  • 0

I have a small sql question for you.

I have two queries:

SELECT tbl_CostPrevisions.Month, SUM(tbl_CostPrevisions.Value) AS 'COST' FROM tbl_CostPrevisions
WHERE tbl_CostPrevisions.Year = @YEAR
GROUP BY tbl_CostPrevisions.Month

SELECT tbl_IncomePrevisions.Month, SUM(tbl_IncomePrevisions.Value) AS 'INCOME' FROM tbl_IncomePrevisions
WHERE tbl_IncomePrevisions.Year = @YEAR
GROUP BY tbl_IncomePrevisions.Month

Giving as the result something like:

1   48550,41
2   61082,86
3   49479,63
4   46529,74
5   46549,74
6   48619,63
7   49649,63
8   48279,92
9   48192,42
10  48467,42
11  48201,42
12  48262,42

And

1   8123,16
2   9174,15
3   50009,12
4   50705,00
5   31971,00
6   15217,00
7   13151,00
8   9677,00
9   9616,00
10  9653,00
11  9698,00
12  9605,00

How can I write just one query that will give me the following result?

1   48550,41    8123,16
2   61082,86    9174,15
3   49479,63    50009,12
4   46529,74    50705
5   46549,74    31971
6   48619,63    15217
7   49649,63    13151
8   48279,92    9677
9   48192,42    9616
10  48467,42    9653
11  48201,42    9698
12  48262,42    9605

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-01T11:04:09+00:00Added an answer on June 1, 2026 at 11:04 am

    try the following inner join:

    SELECT tbl_CostPrevisions.Month, SUM(tbl_CostPrevisions.Value) AS 'COST' , SUM(tbl_IncomePrevisions.Value) AS 'INCOME'
    FROM tbl_CostPrevisions
    INNER JOIN tbl_IncomePrevisions on tbl_CostPrevisions.Month = tbl_IncomePrevisions.Month
    WHERE tbl_CostPrevisions.Year = @YEAR AND tbl_IncomePrevisions.Year = @YEAR
    GROUP BY tbl_CostPrevisions.Month
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to sql. i have a small question. i have two tables
I have this small SQL query. SELECT a.`id` , a.`title` , a.`date` , (
SQL to find duplicate entries (within a group) I have a small problem and
i am new to SQL and i have a small question. i am writing
I have a small question about stored procedures and the DateTime2 datatype in SQL
I have many small files containing code fragments, pseudo-code algorithms, classes, templates, SQL-samples, etc.,
I have limited SQL background, basically a small amount of manipulation through HTML and
I have a question about the SQL standard which I'm hoping a SQL language
I have a small database which is legacy from an almost defunct project. This
I have question I'm developing small application to desktop in win Forms. I'm using

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.