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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:46:55+00:00 2026-05-27T21:46:55+00:00

There are two tables with the same structure: ‘imsc_storage_users’ & ‘imsc_storage_users_archive’. My current SELECT/UNION:

  • 0

There are two tables with the same structure: ‘imsc_storage_users’ & ‘imsc_storage_users_archive’.

My current SELECT/UNION:

SELECT `cli`,`ts`,`questions`, `answers`,`correct`,`last`,`minutes` 
FROM  `imsc_storage_users`
UNION DISTINCT
SELECT `cli`,`ts`,`questions`, `answers`,`correct`,`last`,`minutes` 
FROM  `imsc_storage_users_archive`
ORDER BY `correct` DESC,`minutes` ASC

I’m getting these results:

+--------------+---------------------+-----------+---------+---------+------+---------+
| cli          | ts                  | questions | answers | correct | last | minutes |
+--------------+---------------------+-----------+---------+---------+------+---------+
| 111111111111 | 2011-12-22 11:13:57 |        30 |      29 |      14 |   30 | 1305.47 |
| 222222222222 | 2011-12-15 13:39:16 |        26 |      24 |      13 |   24 |   15.67 |
| 333333333333 | 2011-12-15 13:39:39 |        26 |      25 |      11 |   25 |   15.18 |
| 444444444444 | 2011-12-15 13:39:39 |        25 |      21 |      11 |   25 |  280.53 |
| 111111111111 | 2011-12-22 11:13:57 |        25 |      21 |      10 |   25 |  373.87 |
| 555555555555 | 2011-12-19 15:46:15 |        11 |      10 |       5 |   10 |     3.8 |
| 666666666666 | 2011-12-15 13:39:16 |        14 |      10 |       4 |   10 |  321.64 |
| 777777777777 | 2011-12-19 08:34:36 |        15 |      11 |       4 |   13 |  474.66 |

Notice that ‘111111111111’ appears twice?

I want it to be combined, so in the results set I get one row of ‘111111111111’ which combines/sums all fields; ‘questions’ =>> 55…. etc’.

What would be the correct SQL?
Performance are NOT of an issue here.

Thank you!

  • 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-05-27T21:46:56+00:00Added an answer on May 27, 2026 at 9:46 pm
    SELECT `cli`,max(`ts`) AS ts, sum(`questions`) as questions, sum(`answers`) as answers,sum(`correct`) as correct,sum(`last`) as last,sum(`minutes`) as minutes
    FROM (
      SELECT `cli`,`ts`,`questions`, `answers`,`correct`,`last`,`minutes` 
      FROM  `imsc_storage_users`
      UNION ALL
      SELECT `cli`,`ts`,`questions`, `answers`,`correct`,`last`,`minutes` 
      FROM  `imsc_storage_users_archive`
    ) AS baseview
    GROUP BY cli
    ORDER BY `correct` DESC,`minutes` ASC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to merge two SELECT statements. There are two tables in my database,
I want to paginate two database tables having same structure(eg SMS and MMS) which
There are two tables with identical structure. Let's assume the number of rows in
I have two tables table1 and table2 . Both tables have the same structure.
I have two tables which have the exact same structure. Both tables can store
I have two tables (let's call them A and B) with same structure and
There are two tables. One is users info users, one is comments info comments.
alt text http://img502.imageshack.us/img502/7245/75088152.jpg There are two tables that I join them together, one of
One doubt in MSSQL. There are two tables in a databases. Table 1 named
I am developing a student registration form in asp.net. there are two tables viz

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.