1/19
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No study sessions yet.
What is the correct order for SQL clauses?
A) ORDER BY, GROUP BY, HAVING, WHERE, FROM, SELECT
B) SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY
C) SELECT, WHERE, FROM, HAVING, GROUP BY, ORDER BY
D) SELECT, FROM, GROUP BY, WHERE, HAVING, ORDER BY
Answer: B
What can be in the SELECT clause?
A) Filters and conditions
B) Aggregates without GROUP BY
C) Column names, expressions, aliases, aggregates (if GROUP BY is used)
D) HAVING conditions
Answer: C
What cannot be in the SELECT clause?
A) Aliases
B) Filters, conditions, aggregates without GROUP BY
C) Column names
D) Expressions
Answer: B
What can be in the WHERE clause?
A) Aggregates like AVG()
B) Row-level filters, comparisons, logical operators (AND, OR, NOT)
C) HAVING conditions
D) GROUP BY keywords
Answer: B
What cannot be in the WHERE clause?
A) Logical operators
B) Aggregate functions like AVG(), COUNT(), SUM()
C) Column names
D) Expressions
Answer: B
What can be in the GROUP BY clause?
A) Aliases
B) Columns used in SELECT or aggregate functions
C) Expressions not in SELECT
D) DESC keyword
Answer: B
What cannot be in the GROUP BY clause?
A) Columns
B) DESC keyword
C) Expressions used in SELECT
D) Aggregates
Answer: B
What can be in the HAVING clause?
A) Row-level filters
B) Conditions on aggregated results (e.g., HAVING AVG(price) > 100)
C) Logical operators only
D) Non-aggregated filters
Answer: B
What cannot be in the HAVING clause?
A) Conditions on aggregates
B) Filters on grouped data
C) Non-aggregated filters (use WHERE instead)
D) AVG() and COUNT()
Answer: C
What can be in the ORDER BY clause?
A) Column names, aliases, expressions, ASC/DESC
B) GROUP BY expressions
C) HAVING conditions
D) Aggregates only
Answer: A
What cannot be in the ORDER BY clause?
A) Column names
B) Grouping logic or filters
C) Aliases
D) ASC/DESC
Answer: B
What is the correct SQL clause order?
A) SELECT → FROM → WHERE → GROUP BY → HAVING → ORDER BY
B) SELECT → FROM → GROUP BY → WHERE → HAVING → ORDER BY
C) SELECT → WHERE → FROM → GROUP BY → ORDER BY → HAVING
D) SELECT → FROM → HAVING → WHERE → GROUP BY → ORDER BY
Answer: A
GROUP BY vs ORDER BY – what is the key difference?
A) GROUP BY sorts rows; ORDER BY filters rows
B) GROUP BY filters rows; ORDER BY groups rows
C) GROUP BY groups rows; ORDER BY sorts rows or groups
D) GROUP BY and ORDER BY do the same thing
Answer: C
GROUP BY vs ORDER BY – are they independent?
A) No – they must be used together
B) Yes – they are independent; one does not require the other
C) No – ORDER BY depends on GROUP BY
D) Yes – but only if HAVING is used
Answer: B
Can you use ORDER BY without GROUP BY?
A) No
B) Only with HAVING
C) Yes – ORDER BY works on rows even without grouping
D) Only with aggregates
Answer: C
Can you use GROUP BY without ORDER BY?
A) No
B) Only with WHERE
C) Yes – GROUP BY groups data regardless of sort order
D) Only with sorting
Answer: C
How do you sort by multiple fields?
A) ORDER BY field1, field2
B) ORDER BY field1 ASC, field2 DESC
C) GROUP BY field1, field2
D) HAVING field1, field2
Answer: B
Why does GROUP BY have nothing to do with ordering?
A) It only sorts rows
B) It only filters rows
C) It only groups rows for aggregation
D) It only applies HAVING
Answer: C
Why does ORDER BY have no impact on grouping?
A) It only filters rows
B) It only sorts rows or groups
C) It only applies HAVING
D) It only groups rows
Answer: B
Can GROUP BY and ORDER BY appear together?
A) No – they are mutually exclusive
B) Yes – they are independent and can be used together or separately
C) Only with HAVING
D) Only with WHERE
Answer: B