Sector file // sql
SQLDECODED.
Joins, indexes & queries
Easy
15 questionsStart hereWhat is the difference between a primary key and a foreign key?
DSA ยท 1.2k views ยท primary-key, foreign-key
What is the difference between a primary key and a unique constraint?
DSA ยท 1.1k views ยท constraints
What is the logical order of execution of a SQL query?
DSA ยท 1.1k views ยท order-of-execution
What is the CASE expression?
DSA ยท 1.0k views ยท case
What are the different types of SQL joins?
DSA ยท 1.0k views ยท sql, joins
What is the difference between WHERE and HAVING?
DSA ยท 1.0k views ยท where, having
What does DISTINCT do and what is its cost?
DSA ยท 860 views ยท distinct
How do you find duplicate rows in a table?
DSA ยท 695 views ยท duplicates, group-by
Medium
51 questionsTop-N per group with RANK() OVER (PARTITION BY) โ how do you get top 2 per department without collapsing rows?
DSA ยท 1.2k views ยท window-functions, rank, partition
What is database normalization?
DSA ยท 1.2k views ยท normalization
Advanced UPSERT patterns โ conditional updates, xmax detection, and soft-delete-aware indexes?
System Design ยท 1.2k views ยท upsert, idempotency, constraints
Covering indexes (INCLUDE) and Bitmap Heap Scans โ how do you eliminate heap fetches in 2025?
System Design ยท 1.2k views ยท covering-index, bitmap-scan, vacuum
What is a subquery and what is a correlated subquery?
DSA ยท 1.2k views ยท subquery
LATERAL JOIN โ how do you fetch the top 3 orders per customer efficiently?
DSA ยท 1.2k views ยท lateral-join, top-n, postgres
How do you read an EXPLAIN query plan?
DSA ยท 1.1k views ยท explain
What is a covering index?
DSA ยท 1.1k views ยท covering-index
Hard
16 questionsJSONB vs normalized columns vs EAV โ how do you model flexible attributes without killing query performance?
System Design ยท 1.1k views ยท jsonb, data-modeling, schema-design
Serializable isolation pitfalls โ write skew, retry storms, and when advisory locks beat SSI?
System Design ยท 1.1k views ยท isolation, serializable, write-skew
RANK() vs DENSE_RANK() vs ROW_NUMBER() โ when does the gap matter and how do you choose?
DSA ยท 1.1k views ยท window-functions, ranking, dense-rank
How do recursive CTEs work?
DSA ยท 1.1k views ยท recursive-cte
What is a LATERAL join?
DSA ยท 1.0k views ยท lateral
SKIP LOCKED for job queues โ how do you build a concurrent queue without race conditions?
System Design ยท 863 views ยท skip-locked, queue, concurrency
How do you optimize a slow SQL query?
DSA ยท 819 views ยท query-optimization
How do you pivot rows into columns?
DSA ยท 654 views ยท pivot
Seen a SQL question that is not here? Add it and help the next candidate.
Share a question