Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Adding sum of certain rows and cols to my query

User_BY2GENov 15 2022

hello everyone. Im really clueless in sql to say the least. I have the following query and it's result :
queryresult.png (35.47 KB)
ON TOP of that I want to be able to add a column name TOTAL which will sum each row (for example first row Total=3).
Also I want to add TWO !ROWS! as sum of the targeted column's rows, so for example
I want to create a new Row with (SUM of status 2 4 and 5) and a total sum of all statuses like shown below :
sums.png (24.94 KB)

Ive tried adding to the First query row (select * from) --> select status,1,2,3,5, 1+2+3+5 as Total aswell as COALESCE and even Rollup() but the results were nothing near.
something else I dont understand is, why whenever I change my select * statement to specific columns, it will fill the rows with the column's value's data?? for exaple if I changed my select to (select status, 1) from, it will fill the column 1 row's value to 1 ??:
status,1.png (29.71 KB)
Any help will be appreciated much, thanks !!

Comments

Processing

Post Details

Added on Nov 15 2022
3 comments
3,912 views