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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:24:27+00:00 2026-06-12T10:24:27+00:00

I have two rows in a table. I want to add in a third

  • 0

I have two rows in a table. I want to add in a third row which holds the total value.

My table is

SELECT 
CONTROLLED_PERCENTAGE, EL_CLIENT_ID, ID, 
   PERC_ADJ_UNITS_RECEIVED, PHY_DIG_OR_TOTAL, RECORDING_ID, 
   SUM_UNITS_RECEIVED, UNIT_TYPE
FROM EL_CLIENT_REC_UNITS;

I will have the EL_CLIENT_ID, UNIT_TYPE, PHY_DIG_OR_TOTAL will be ‘PHY’ or ‘DIG’ and I am looking to get the total. I want to add up the two record’s SUM_UNITS_RECEIVED and PERC_UNITS_RECEIVED where the UNIT_TYPES, EL_CLIENT_ID and RECORDING_IDs are the same. I then want to insert this as a new row with the same UNIT_TYPE, RECORDING_ID but this time have PHY_DIG_OR_TOTAL set to ‘TOTAL’;

  • 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-12T10:24:28+00:00Added an answer on June 12, 2026 at 10:24 am

    Try something like this:

    SELECT 
        ID, 
        EL_CLIENT_ID, 
        RECORDING_ID, 
        UNIT_TYPE,
        PHY_DIG_OR_TOTAL, 
        CONTROLLED_PERCENTAGE, 
        SUM_UNITS_RECEIVED, 
        PERC_ADJ_UNITS_RECEIVED
    FROM EL_CLIENT_REC_UNITS
    
    UNION ALL -- concatenate sets
    
    SELECT 
        NULL                         AS ID, -- No ID for this row
        EL_CLIENT_ID                 AS EL_CLIENT_ID, 
        RECORDING_ID                 AS RECORDING_ID, 
        UNIT_TYPE                    AS UNIT_TYPE, 
        'TOTAL'                      AS PHY_DIG_OR_TOTAL, 
        AVG(CONTROLLED_PERCENTAGE)   AS CONTROLLED_PERCENTAGE,  -- I don't know what to do with that
        SUM(PERC_ADJ_UNITS_RECEIVED) AS PERC_ADJ_UNITS_RECEIVED,
        SUM(SUM_UNITS_RECEIVED)      AS SUM_UNITS_RECEIVED
    FROM EL_CLIENT_REC_UNITS
    GROUP BY UNIT_TYPE, EL_CLIENT_ID, RECORDING_ID;
    

    Try to google for GROUP BY SQL statement to learn more about this statement.

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

Sidebar

Related Questions

I have a really simple table with two rows and two columns. I want
I have two tables - forum_topics and topics_posts . I want to select rows
I have a table to which i dynamically add rows. The number of days
I have a table with 50 columns. It has two rows inserted. I want
I have a two columns and I want to add the value of every
I have two columns in my table and the rows are created dynamically. <table
I have a large table (~1M rows now, soon ~10M) that has two ranked
I have a table with a few thousand rows. The table contains two columns,
I have a very simple table with two columns, but has 4.5M rows. CREATE
I have two tables invoices and pending_payments both of which have the following rows

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.