Comments - GROUP BY

3 months ago Ian Gilfillan

Because 'wins' in single quotes doesn't exist, so the latter query is essentially the same as

SELECT wins, COUNT(*) FROM plays GROUP BY NULL;
+------+----------+
| wins | COUNT(*) |
+------+----------+
|    5 |        4 |
+------+----------+

You may have been trying to use backticks (see Identifier Names):

SELECT wins, COUNT(*) FROM plays GROUP BY `wins`;
+------+----------+
| wins | COUNT(*) |
+------+----------+
|    3 |        1 |
|    5 |        1 |
|    8 |        2 |
+------+----------+
 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.