1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to SQL Server

Connected

Exercise

MIN, MAX and AVG

Along with summing and counting, you'll frequently need to find the minimum, maximum, and average of column values. Thankfully, T-SQL has functions you can use to make the task easier!

Instructions 1/3

undefined XP
  • 1

    Find the minimum value from the affected_customers column, but only for rows where demand_loss_mw has a value. Name the result min_affected_customers.

  • 2

    Amend the query to return the maximum value from the same column, this time aliasing as max_affected_customers.

  • 3

    Return the average value from the affected_customers column, this time aliasing as avg_affected_customers.