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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:26:03+00:00 2026-05-18T05:26:03+00:00

Given that I have a table contains user data, like this: userID calltime result

  • 0

Given that I have a table contains user data, like this:

userID     calltime     result 
1         10:20         1
1         11:00         2
1         11:30         1
2         9:30          1
2         11:00         1
3         10:00         1
3         10:30         2
3         11:00         1
3         11:30         2

Now I want to summarize it like that:

userID     result1    result2
1             2         1
2             2         0
3             2         2
(total)       6         3

for me, summarizing user data is fine, but how can I add total row in a query? UNION does not work with this.

Thank you so much for this.

EDIT: this my current query, of course, it does not work:

  PROCEDURE P_SUMMARIZE_CALL
  (
    pStartDate IN DATE,
    pEndDate IN DATE,
    SummaryCur  OUT MEGAGREEN_CUR    
  )
  IS
  BEGIN
    OPEN SUMMARYCUR FOR
    SELECT USERID, TOTALCALLS,CONNECTEDCALLS,RATE,NOANSWER FROM
    (((SELECT USERID,
            count(CALLID) AS TOTALCALLS, 
            sum(CONNECTED) as CONNECTEDCALLS, 
            sum(CONNECTED)/count(CALLID)*100 || '%' AS RATE,
            (count(CALLID) - sum(CONNECTED)) AS NOANSWER 
    FROM CALLLOGS
    WHERE STARTTIME BETWEEN pStartDate AND pEndDate  
   group by USERID) c
   FULL OUTER JOIN USERS u
   ON c.USERID = u.ID)

    UNION ALL 
     (SELECT NULL,count(CALLID) AS TOTALCALLS, 
            sum(CONNECTED) as CONNECTEDCALLS, 
            sum(CONNECTED)/count(CALLID)*100 || '%' AS RATE,
            (count(CALLID) - sum(CONNECTED)) AS NOANSWER 
    FROM CALLLOGS
    WHERE STARTTIME BETWEEN pStartDate AND pEndDate group by NULL));   

  END;
  • 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-18T05:26:03+00:00Added an answer on May 18, 2026 at 5:26 am

    I assume you are using GROUP BY to generate your current result. (PS: Please post your current query as it is rather hard to guess what you are doing to get that result).

    To get what you want use GROUP BY ROLLUP instead of GROUP BY.

    UNION does not work with this.

    Yes, actually that will work too. But I’d suggest UNION ALL rather than UNION as your result set seems to already to contain only distinct rows so there is no point using extra calculation time searching for duplicate rows to remove.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got 2 tables: Contacts and Users . Contacts table contains user_id which
I have the following php script that allows me perform some calls to other
Good day... I have huge trouble with this and it drives me insane. My
I have a table where one or more entries with the same 'id' value
I have a table containing a large number of rows. Each row has 2
I have a table containing a large number of rows. Each row has 2
For my site, I have a list of users and a list of events.
How do I obtain the user's edit input on a custom model JTable created
I have an application which has the following characteristics There are Clubs Each Club
I've been banging my head on this one for a while and I figured

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.