Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

mysql not a group by clause

SELECT a, b, sum(c) FROM my_table GROUP BY a;		-- Error
SELECT a, b, sum(c) FROM my_table GROUP BY a, b;	-- OK, all expressions there
-- CASE WHEN statement, for example:
SELECT a, CASE WHEN b=1 THEN 'Ok' ELSE 'Ko' END AS r, sum(c) 
FROM my_table
GROUP BY a, CASE WHEN b=1 THEN 'Ok' ELSE 'Ko' END;		-- No alias name (r)
 
PREVIOUS NEXT
Tagged: #mysql #group #clause
ADD COMMENT
Topic
Name
6+9 =