0
0
DBMS Theoryknowledge~5 mins

SELECT with WHERE, ORDER BY, GROUP BY in DBMS Theory - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AGROUP BY
BORDER BY
CWHERE
DHAVING
What does ORDER BY column_name DESC do?
ASorts rows by column_name in descending order
BFilters rows where column_name is DESC
CGroups rows by column_name
DSorts rows by column_name in ascending order
Which clause is used to group rows with the same value in a column?
AWHERE
BGROUP BY
CORDER BY
DSELECT
If you want to filter groups after grouping, which clause do you use?
AHAVING
BORDER BY
CGROUP BY
DWHERE
In which order are these clauses processed in a query: WHERE, GROUP BY, ORDER BY?
AORDER BY, WHERE, GROUP BY
BGROUP BY, ORDER BY, WHERE
CGROUP BY, WHERE, ORDER BY
DWHERE, GROUP BY, ORDER BY
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.