MulaiMulai sekarang secara gratis

HAVING and sorting

Filtering and sorting go hand in hand and gives you greater interpretability by ordering our results.

Let's see this magic at work by writing a query showing what countries have the highest average film budgets.

Latihan ini adalah bagian dari kursus

Intermediate SQL

Lihat Kursus

Petunjuk latihan

  • Select the country and the average budget as average_budget, rounded to two decimal, from films.
  • Group the results by country.
  • Filter the results to countries with an average budget of more than one billion (1000000000).
  • Sort by descending order of the average_budget.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

-- Select the country and average_budget from films
___
-- Group by country
___
-- Filter to countries with an average_budget of more than one billion
___
-- Order by descending order of the aggregated budget
___
Edit dan Jalankan Kode