Skip to content
Advertisement

oracle sum by column without using union

I have this table: (supply table: how many products in storages)

I should write a query to have this result:

“Total_except_storage_30” has the total of every product in storages except storage number 30. For example first “total_except_storage_30” is for product_id 1000 in all storages except storage_id 30 and the second is for product_id 1001.

*** I am not allowed to use “Union”.

I tried to use full outer join but this did not work and the result is without “total_except_storage_30”:

Advertisement

Answer

Something like this should do it

Here’s an example of that using the standard EMP, DEPT

You can see you get subtotals throughout

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