The GROUP BY Clause

On Day 4, “Molding Data with Built-in Functions,” you learned how to use aggregate functions (COUNT, SUM, AVG, MIN, and MAX). If you wanted to find the total amount of money spent from the modified CHECKS table, you would type

						SELECT *
						FROM CHECKS;
					

Here's the modified table:

CHECKNUM PAYEE       AMOUNT          REMARKS
======== =========== =============== ======================

 1 MA BELL                          150 HAVE SONS NEXT TIME
 2 READING R.R.                  245.34  TRAIN TO CHICAGO
 3 MA BELL                       200.33 CELLULAR PHONE
 4 LOCAL UTILITIES                   98 GAS
 5 JOES STALE $ DENT 150 GROCERIES 16 CASH 25 WILD NIGHT OUT 17 JOANS GAS 25.1 GAS 9 ABES CLEANERS 24.35 X-TRA STARCH 20 ABES CLEANERS 10.5 ALL DRY CLEAN 8 CASH 60 TRIP TO BOSTON 21 CASH 34 TRIP TO DAYTON 30 LOCAL UTILITIES 87.5 WATER ...

Get Sams Teach Yourself SQL in 21 Days, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.