Day 5

Quiz

1: When performing aggregate functions (SUM(column_name)) must you group on any nonaggregate columns in your select statement?
A1: Yes, when using aggregate functions in a query, all columns that are not associated with aggregate functions must be listed in the GROUP BY clause.
2: What is the function of the GROUP BY clause, and what other clause does it act like?
A2: The GROUP BY clause groups data result sets that have been manipulated by various functions. The GROUP BY clause acts like the ORDER BY clause in that it orders the results of the query in the order the columns are listed in the GROUP BY.
3: Will this SELECT work?
SQL> SELECT NAME, AVG(SALARY), DEPARTMENT
										FROM PAY_TBL
										WHERE DEPARTMENT = 'ACCOUNTING'
										ORDER BY NAME
										GROUP BY ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.