Grouping by multiple columns
Can we group observations based on multiple columns? For example, we can group all cars by year and engine size and find the most expensive within these.
To group by multiple columns use the same approach as for sorting by multiple columns: just put it within GROUP BY
statement separated with a comma. The query for the example above will look like this:
123SELECT year, enginesize, AVG(price) FROM audi_cars GROUP BY year, enginesize
Swipe to start coding
From the audi_cars
table calculate the maximum, average, and minimum price
for each model
manufactured in different year
s.
Oplossing
Bedankt voor je feedback!
single
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.
Awesome!
Completion rate improved to 2.63Awesome!
Completion rate improved to 2.63
Grouping by multiple columns
Can we group observations based on multiple columns? For example, we can group all cars by year and engine size and find the most expensive within these.
To group by multiple columns use the same approach as for sorting by multiple columns: just put it within GROUP BY
statement separated with a comma. The query for the example above will look like this:
123SELECT year, enginesize, AVG(price) FROM audi_cars GROUP BY year, enginesize
Swipe to start coding
From the audi_cars
table calculate the maximum, average, and minimum price
for each model
manufactured in different year
s.
Oplossing
Bedankt voor je feedback!
single
Awesome!
Completion rate improved to 2.63
Grouping by multiple columns
Veeg om het menu te tonen
Can we group observations based on multiple columns? For example, we can group all cars by year and engine size and find the most expensive within these.
To group by multiple columns use the same approach as for sorting by multiple columns: just put it within GROUP BY
statement separated with a comma. The query for the example above will look like this:
123SELECT year, enginesize, AVG(price) FROM audi_cars GROUP BY year, enginesize
Swipe to start coding
From the audi_cars
table calculate the maximum, average, and minimum price
for each model
manufactured in different year
s.
Oplossing
Bedankt voor je feedback!