MS SQL Aggregate Functions for beginners – COUNT, SUM, MAX, MIN



MS SQL Aggregate Functions for beginners – COUNT, SUM, MAX, MIN

MS SQL Aggregate Functions for beginners - COUNT, SUM, MAX, MIN

This is a Microsoft SQL tutorial on Aggregate Functions. This includes COUNT, SUM, MAX, MIN and AVG. I will show, through examples, how to write Aggregate Functions, limiting results and error handling.

Errors discussed:
– Column is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
– An aggregate may not appear in the WHERE clause unless it is in a subquery contained in a HAVING clause or a select list, and the column being aggregated is an outer reference.