Skip to content
Advertisement

How to count all distinct rows?

If I have a table like below, how can I count and sum all distinct values?

The output I desire is following for each class. So for class 8 it would be:

Advertisement

Answer

You could use GROUPING SETS:

db<>fiddle demo

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