Skip to content
Advertisement

How to calculate oracle column data with group by

I want to calculate different columns from different tables. i am trying to get my required result from my code but the result give me twice same rows of data

i have 3 tables in my oracle database rolls_purchase,rolls_issue,rolls_consumption

when i purchase rolls and put data into my rolls_purchase table,i got result correctly,after that i use rolls_issue form for issue roll then my form coding doing well, 3rd step is when a user consumed the roll,if there are some left and returned to me,i need to add them back when i use my code then the result gives me twice same rows like as below.

above codes result is

i need this result ,if issue my rolls then above code calculate my rolls group by and sum them only one row like below

Advertisement

Answer

Use only p.quality,p.roll_size within grouping clause(I just replaced the alias x with p)

Use such a query with join :

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement