Skip to content
Advertisement

SQL group by with condition

Imagine i have a table like below:

where score can have an intger value between 0 and 100. I want to group by score, which can be done with something like:

How do I add a condition in the group by if I want to group scores > 20 in one group?

I have tried:

but get a “not a GROUP BY expression”

Advertisement

Answer

You need to repeat the same expression with SELECT statement :

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