Using CASE WHEN as a GROUP


#1

I’ve been playing around with the GROUP BY syntax trying to understand it better.
In the exercise for CASE WHEN, the “passing” syntax requires “GROUP BY 1”.I attempted to change that to GROUP BY 2 and then GROUP BY COUNT() but get an error code stating aggregate functions are not allowed in the GROUP BY clause.
My confusion comes from my understanding that the CASE WHEN process is an aggregate function as well. Why does the CASE WHEN language work with GROUP BY but COUNT(
) does not.

```

Replace this line with your code.

<do not remove the three backticks above>

#2

If you use the group-by as
GROUP BY 1
you are grouping on the first field mentioned in your select

count() will produce a total of ROWS-nr

do a google search
sql where can count() be used site:stackoverflow.com
or for possible solutions to your problem
sql aggregate functions are not allowed in the GROUP BY clause. site:stackoverflow


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.