10 Grouping Data Flashcards
Purpose of grouping data?
Dividing data into logical sets so you can perform aggregate (grouped) calculations on each group
How many columns can you have in a GROUP BY clause?
As many as you want which provides more granular control over how the data is grouped
How is a nested group in a GROUP BY clause summarized?
Data is summarized at the last specified group, which evaluates all specified columns together so you won’t get data back for each individual column level
What types of columns can be used in the GROUP BY clause?
It must be a retrieved column (from your select statement) or a valid expression.
What types of columns CANNOT be used in the GROUP BY clause?
It CANNOT be an aggregate function or an alias.
Which columns in your select statement must be present in the GROUP BY clause?
All of them, except for the aggregate calculation statements
If the grouping column contains multiple rows with a NULL value, what happens?
All of null VALUE rows will be grouped together
The GROUP BY clause must be placed in what location?
Between WHERE and ORDER BY
It must be after the WHERE clause and before the ORDER BY clause
What is the difference between the WHERE and HAVING filter?
WHERE filters rows
HAVING filters groups
When using a GROUP BY clause, what clause should also always be specified?
ORDER BY should always be specified to make sure the data will be sorted properly
What is the order in which SELECT statement clauses are to be specified?
SELECT
FROM
WHERE
GROUP BY
HAVING
ORDER BY