Skip to content
Advertisement

Display value in column although it is excluded by a WHERE condition over another column

DB-Fiddle

Expected Result:


In the result above I want to list all itemID and orderID that have shipped_volume > 0.
Therefore, I went with this query:

It gives me almost the result I am looking for.
The only issue I have is that it puts a 0 for all rows in column sum(order_volume) which is caused by the WHERE condition.

What do I need to change so it also displays the sum(order_volume) of all items and orders that have a shipped_volume > 0?

Advertisement

Answer

This may be what you are looking for if i understand correctly :

FIND A DEMO HERE

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