not a group by expression case statement

Solutions on MaxInterview for not a group by expression case statement by the best coders in the world

showing results for - "not a group by expression case statement"
Aymane
23 Jun 2019
1SELECT a, b, sum(c) FROM my_table GROUP BY a;		-- Error
2SELECT a, b, sum(c) FROM my_table GROUP BY a, b;	-- OK, all expressions there
3-- CASE WHEN statement, for example:
4SELECT a, CASE WHEN b=1 THEN 'Ok' ELSE 'Ko' END AS r, sum(c) 
5FROM my_table
6GROUP BY a, CASE WHEN b=1 THEN 'Ok' ELSE 'Ko' END;		-- No alias name (r)