I know it's too late to ask but what does group by do?

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/en/courses/sql-table-transformation/lessons/conditional-aggregates/exercises/case-when?action=lesson_resume&link_content_target=interstitial_lesson

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
Hello I don’t understand what does the group by do?
I know it’s not the time to ask this but please can anyone explain for me? For example what does the group by do in this code?
Thanks in advance for any feedback. :cherry_blossom:
<In this course, it often helps to include a screenshot of your whole web browser – that lets everyone see what you see. If you wish to include a screenshot, add it below this line.>

<If you wish to copy/paste in your code, you can use this next section. This will allow others to copy/paste your code for testing – something that they won’t be able to do with just a screenshot.>

```

SELECT
CASE
WHEN elevation < 250 THEN ‘Low’
WHEN elevation BETWEEN 250 AND 1749 THEN ‘Medium’
WHEN elevation >= 1750 THEN ‘High’
ELSE ‘Unknown’
END AS elevation_tier
, COUNT(*)
FROM airports
GROUP BY 1;

<do not remove the three backticks above>

I don’t know the exact answer but I think it’s sorting the rows by the thing that we give him. Am I right? or maybe I’m just confused with order by and group by!
*Sorry for my English

http://www.tutorialspoint.com/sql/sql-group-by.htm

1 Like

Thank you.
It was helpful.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.