Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Filters and Aggregators πŸ“

Learning Goals

By the end of this section you will:

  • know how to use the LIMIT clause to restrict the number of rows returned

  • know how to use MAX and MIN to return the highest and lowest values in a field

  • know how to aggregate values of a column using COUNT, AVG and SUM

SQL filter clauses are used to restrict the number of rows returned by a query based on specified conditions, enabling more precise data retrieval and manipulation. While SQL aggregators are functions used to perform calculations on multiple rows of a table’s column and return a single value.

LIMIT ClauseΒΆ

The LIMIT clause in SQL is used to specify the maximum number of rows that a query should return.

Go to the W3schools Tutorial on the TOP, LIMIT, FETCH FIRST or ROWNUM Clauses. Only do the exercise for the LIMIT clause.

MAX and MIN FunctionsΒΆ

The MAX function returns the highest value in a column, while the MIN function returns the lowest value in a column.

Go to the W3schools Tutorial on the MIN() and MAX() functions and complete their exercises.

COUNT, AVG and SUM Functions πŸ“ΒΆ

The COUNT function returns the number of rows, AVG calculates the average of numeric values, and SUM adds up all the numeric values in a column.

W3schools Tutorial on the COUNT, AVG and SUM Functions and complete their exercises.