GROUP BY/ORDER BY
redbilledpanda opened this issue · 1 comments
I'm looking at examples from the notes and I've come across this sql snippet:
SELECT year, month, count(*) as record_count
FROM station_data
WHERE tornado = 1
GROUP BY year, month
I've realized that count(*) as record count
is not really required in this example which can be shortened to
SELECT year, month FROM station_data
WHERE tornado = 1
GROUP BY year, month;
so could you please explain what the aggregation above does or why is it needed? Is it to count the number of records of each distinct type?
I'm looking at examples from the notes and I've come across this sql snippet:
SELECT year, month, count(*) as record_count FROM station_data WHERE tornado = 1 GROUP BY year, month
I've realized that
count(*) as record count
is not really required in this example which can be shortened toSELECT year, month FROM station_data WHERE tornado = 1 GROUP BY year, month;
so could you please explain what the aggregation above does or why is it needed? Is it to count the number of records of each distinct type?
That is correct. It's to break up the count by year and month.