Sector file // sql
SQLDECODED.
Joins, indexes & queries
82 Questions56.3k Views3.4k Upvotes
15 easy51 med16 hard
Easy
3 questionsWhat is the difference between a primary key and a unique constraint?
DSA · 1.1k views · constraints
Views:1.1kLikes:32
What is the logical order of execution of a SQL query?
DSA · 1.1k views · order-of-execution
Views:1.1kLikes:70
What does DISTINCT do and what is its cost?
DSA · 859 views · distinct
Views:859Likes:59
Medium
14 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
Views:1.2kLikes:74
Advanced UPSERT patterns — conditional updates, xmax detection, and soft-delete-aware indexes?
System Design · 1.2k views · upsert, idempotency, constraints
Views:1.2kLikes:4
How do you aggregate values into a single string?
DSA · 1.1k views · string-agg
Views:1.1kLikes:22
What is the difference between COUNT(*), COUNT(col), and COUNT(DISTINCT col)?
DSA · 967 views · count
Views:967Likes:68
Why might EXISTS outperform a JOIN for existence checks?
DSA · 948 views · exists, performance
Views:948Likes:35
How does SQL handle NULL values?
DSA · 940 views · null
Views:940Likes:73
Filtered vector search with pgvector — how do you combine WHERE category = 'X' with ORDER BY embedding <=> $1?
System Design · 752 views · pgvector, filtering, ann
Views:752Likes:66
What is the difference between ROW_NUMBER, RANK, and DENSE_RANK?
DSA · 740 views · window, ranking
Views:740Likes:7
Hard
4 questionsRANK() 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
Views:1.1kLikes:48
How do you optimize a slow SQL query?
DSA · 816 views · query-optimization
Views:816Likes:67
How do you pivot rows into columns?
DSA · 651 views · pivot
Views:651Likes:77
Why does column order matter in a composite index?
DSA · 585 views · composite-index
Views:585Likes:77
Seen a SQL question that is not here? Add it and help the next candidate.
Share a question