O'Reilly logo

Discovering SQL: A Hands-On Guide for Beginners by Alex Kriegel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

SUMMARY

Grouping and aggregation in SQL provide a user with a 10,000-foot view of the data, as opposed to the minute details of individual records. The aggregated data is returned as a single record, regardless of how many individual records there might be in the table. SQL aggregate functions are mostly used with numeric data, and some could work with other data types (such as characters and dates). Aggregate functions could employ additional DISTINCT keywords to filter data prior to aggregation.

More than a single record could be returned with aggregate SQL functions when used in conjunction with the GROUP BY clause, which groups aggregate values based on criteria specified in the clause. To allow for an additional selection filter based upon aggregated values, a special HAVING clause is used, which acts as a WHERE clause for the GROUP BY data sets.

The returned records could be further ordered using the ORDER BY clause, which is the final filter applied to the records returned by a query.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required