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

  • Home
  • SEARCH
  • 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 8506979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:44:26+00:00 2026-06-11T02:44:26+00:00

See the following SQL: SELECT M.username, count(*) as Total, date(status_date) as Date FROM com_result

  • 0

See the following SQL:

SELECT M.username, count(*) as Total, date(status_date) as Date FROM com_result
   LEFT JOIN members as M on M.member_id = com_result.member_id 
GROUP BY date(status_date), com_result.member_id  Order By status_date DESC

This will show total numbers of records base on DATE and member_id

Example Result:

+----------+-------+------------+
| username | Total | DATE       |
+----------+-------+------------+
| bx7      |     3 | 2012-09-10 |
| bx2      |    25 | 2012-09-04 |
| bx2      |   401 | 2012-09-03 |
| bx1      |   703 | 2012-09-02 |
| bx4      |  1075 | 2012-09-02 |
+----------+-------+------------+

It work well, now I want to merge/union to another same and its same table structure. Second SQL:

SELECT M.username, count(*) as Total, date(status_date) as Date FROM com_result_b
   LEFT JOIN members as M on M.member_id = com_result_b.member_id 
GROUP BY date(status_date), com_result_b.member_id  Order By status_date DESC

Assume the result from com_result would be:

| bx2   |    25 | 2012-09-04 |

And the result from com_result_b would be:

 | bx2   |    50 | 2012-09-04 |

So when it merged/union – I want the result be like:

 | bx2   |    75 | 2012-09-04 |

As you can see the value of Total increased from same Date from two tables. How can that be done?

  • 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-11T02:44:27+00:00Added an answer on June 11, 2026 at 2:44 am

    With a SUM

    select username,SUM(Total) , DATE
    (
        SELECT M.username, count(*) as Total, date(status_date) as Date FROM com_result_b 
           LEFT JOIN members as M on M.member_id = com_result.member_id  
        GROUP BY date(status_date), com_result.member_id  
       UNION ALL
       SELECT M.username, count(*) as Total, date(status_date) as Date FROM com_result_b   
          LEFT JOIN members as M on M.member_id = com_result_b.member_id    
       GROUP BY date(status_date), com_result_b.member_id 
    ) v
    
    group by username, date
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following SQL statement: SELECT * FROM cars car LEFT JOIN (SELECT
See the following SQL statement: SELECT datediff(d, MAX(invoice.date), Now) As Date_Diff , MAX(invoice.date) AS
Please see the following t-sql code DECLARE @iError INT EXEC('select * from sysobj') SELECT
If I have the following SQL: BEGIN TRANSACTION SELECT val FROM myTable and don't
I have the following SQL Query: SELECT upd.*, usr.username AS `username`, usr.profile_picture AS `profile_picture`
How would the following sql query look when translated to linq? SELECT myId, Count(myId)
I'm making the following SQL call: SELECT dpt_id, dpt_title, dpt_active, dpt_parent FROM tbl_department ORDER
I have the following SQL query: SELECT DISTINCT ProductNumber, PageNumber FROM table I am
I'm using the following SQL query: SELECT * FROM Articles WHERE Name = 'Name'
Given the following SQL: IF EXISTS (SELECT * FROM sys.columns WHERE name = 'NewFieldName'

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.