Skip to content
Advertisement

Oracle SQL group by then sum

I have a table CUST_LOG with data below.

How should I select above as below result? I want to group by CUST_ID then sum each status count by CUST_ID? I used OUTER JOIN but not work.

The only way I found is use UNION clause as the following sql, but it is too complicated if there are many status.

Advertisement

Answer

try the following, here is the demo.

Output:

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