1. Learn
  2. /
  3. 课程
  4. /
  5. SQL Server 入门

Connected

道练习

MIN、MAX 和 AVG

除了求和与计数,您还会经常需要找出列值的最小值、最大值和平均值。好在 T-SQL 提供了相关函数,能让这一任务更轻松!

说明 1/3

undefined XP
  • 1

    在 demand_loss_mw 有值的行中,找出 affected_customers 列的最小值。将结果命名为 min_affected_customers。

  • 2

    修改查询以返回同一列的最大值,这次将别名设为 max_affected_customers。

  • 3

    返回 affected_customers 列的平均值,这次将别名设为 avg_affected_customers。