HAVING 与排序
筛选与排序常常配合使用。通过对结果排序,您可以更好地解读数据。
让我们动手写一条查询,看看哪些国家的平均电影预算最高。
本练习是课程的一部分
SQL 中级
练习说明
- 从
films中选择country,以及四舍五入到 2 位小数的平均预算,命名为average_budget。 - 按
country对结果分组。 - 仅保留平均预算大于 10 亿(
1000000000)的国家。 - 按
average_budget降序排序。
交互式实操练习
通过完成这段示例代码来试试这个练习。
-- 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
___