Skip to main content
Databases & Storage

SQL Relational Queries & Optimization Skill Assessment Quiz (2026)

15 Questions15 MinsPass: 80%

Test your mastery of SQL: Joins, window functions (ROW_NUMBER, DENSE_RANK, OVER), CTEs, indexing B-Trees, transactions (ACID), and query.

Question 1 of 150% Completed
Single Choice

What is the difference between `WHERE` and `HAVING` in an SQL query?

Select an option above

SQL: Assessment Scope & Sample Focus Areas

15 questions • 80% pass target

This interactive technical assessment checks your practical understanding of SQL (Databases & Storage) across syntax behavior, edge cases, and architectural decisions.

Topic 1 of 15

What is the difference between `WHERE` and `HAVING` in an SQL query?

Topic 2 of 15

What is the difference between `UNION` and `UNION ALL`?

Topic 3 of 15

What does `ROW_NUMBER() OVER (PARTITION BY dept_id ORDER BY salary DESC)` compute?

Topic 4 of 15

What is the difference between `RANK()` and `DENSE_RANK()` window functions?

Topic 5 of 15

What is a Common Table Expression (CTE) defined with `WITH cte_name AS (...)`?

Topic 6 of 15

What is an Index Seek vs an Index Scan in query execution plans?

Frequently Asked Questions

SQL Assessment: Key Technical Questions & Answers

5 Questions Answered
1What is the difference between SQL `WHERE` and `HAVING` clauses?
`WHERE` filters rows before any aggregation, grouping, or window functions are computed; it cannot reference aggregate functions (e.g. `WHERE COUNT(*) > 5` is invalid). `HAVING` filters aggregated groups after the `GROUP BY` clause has been executed and can reference aggregate calculations like `HAVING SUM(amount) > 1000`.
2How do SQL Window Functions (`ROW_NUMBER()`, `RANK()`, `DENSE_RANK()`) differ from `GROUP BY`?
`GROUP BY` collapses multiple matching rows into a single summary output row, discarding individual record identity. Window Functions (`OVER (PARTITION BY ... ORDER BY ...)`) compute aggregate and ranking metrics over a sliding frame of rows while retaining the individual identity and cardinality of every row in the output result set.
3What is Database Normalization across 1NF, 2NF, 3NF, and BCNF?
1NF requires atomic column values and unique rows. 2NF requires 1NF and ensures all non-key attributes are fully functionally dependent on the entire composite primary key (eliminating partial dependencies). 3NF requires 2NF and ensures non-key attributes depend strictly on the primary key, eliminating transitive dependencies. BCNF (Boyce-Codd) tightens 3NF by ensuring that every determinant in a functional dependency is a candidate key.
4What is the difference between `UNION` and `UNION ALL` in SQL?
`UNION` combines result sets from two queries and performs an implicit deduplication sort step, stripping all duplicate rows from the final result set (computationally expensive on large tables). `UNION ALL` combines result sets directly without sorting or deduplication, preserving all matching duplicate rows with significantly faster execution.
5How do Correlated Subqueries differ from Non-Correlated Subqueries in performance?
A Non-Correlated Subquery is completely independent of the outer query; the database engine executes it once, caches the result, and uses it to evaluate outer rows. A Correlated Subquery references columns from the outer query row (`WHERE outer.id = inner.user_id`), forcing the database engine to re-evaluate the subquery once for every single candidate row in the outer table, often causing $O(n^2)$ performance degradation unless rewritten as an explicit `JOIN`.

Next Steps for Mastery

Reinforce your knowledge with cheatsheets, interactive sandboxes, and interview prep.