When using the
GROUP BY clause, do we always have to group by one of the selected columns listed after
No, you can
GROUP BY a column that was not included in the
For example, this query does not list the
price column in the
SELECT, but it does group the data by that column.
SELECT name, downloads FROM fake_apps GROUP BY price;
However, usually we do include the grouped by column in the
SELECT for the sake of clarity, so that it’s easier to see what rows belong to which group.