Skip to content
Advertisement

Group by to include case statement inside SQL statement

I have a table which stores purchase info from sellers and table contains rating to every purchase out of 5 stars. I want to have output Group By sellers and Each sellers good(Above 3) and bad(Below 4) ratings count

For first 3 columns I am getting result using this

Unable to identify how to include case in group by clause.

Advertisement

Answer

You are trying to do conditional aggreation. The important thing is that you want the conditional expression inside the aggregate function:

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