Recall & Review
beginner
What does the
WHERE clause do in a SELECT statement?The
WHERE clause filters rows to include only those that meet a specified condition.Click to reveal answer
beginner
How does the
ORDER BY clause affect the result of a SELECT query?The
ORDER BY clause sorts the result rows by one or more columns, either ascending or descending.Click to reveal answer
intermediate
What is the purpose of the
GROUP BY clause in SQL?The
GROUP BY clause groups rows that have the same values in specified columns, often used with aggregate functions like COUNT or SUM.Click to reveal answer
intermediate
Can you use
WHERE and GROUP BY together? If yes, in what order?Yes, you use
WHERE first to filter rows, then GROUP BY to group the filtered rows.Click to reveal answer
intermediate
What happens if you use
ORDER BY after GROUP BY?The query first groups rows, then sorts the grouped results according to the
ORDER BY clause.Click to reveal answer
Which clause filters rows before grouping in a SELECT query?
✗ Incorrect
The WHERE clause filters rows before grouping. HAVING filters after grouping.
What does
ORDER BY column_name DESC do?✗ Incorrect
DESC means descending order, so rows are sorted from highest to lowest.
Which clause is used to group rows with the same value in a column?
✗ Incorrect
GROUP BY groups rows that share the same value in specified columns.
If you want to filter groups after grouping, which clause do you use?
✗ Incorrect
HAVING filters groups after GROUP BY has been applied.
In which order are these clauses processed in a query: WHERE, GROUP BY, ORDER BY?
✗ Incorrect
First WHERE filters rows, then GROUP BY groups them, then ORDER BY sorts the result.
Explain how the WHERE, GROUP BY, and ORDER BY clauses work together in a SELECT query.
Think about the order SQL processes these clauses.
You got /3 concepts.
Describe a real-life example where you would use WHERE, GROUP BY, and ORDER BY in a database query.
Imagine you want to see total sales per region, only for recent months, sorted by highest sales.
You got /4 concepts.