Sector file // sql
SQLDECODED.
Joins, indexes & queries
Easy
9 questionsWhat 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
When would you use a transaction explicitly?
DSA ยท 607 views ยท truncate-vs-delete
What is a CROSS JOIN and when is it useful?
DSA ยท 508 views ยท joins
What is a CHECK constraint?
DSA ยท 125 views ยท check-constraint
Medium
30 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
Advanced UPSERT patterns โ conditional updates, xmax detection, and soft-delete-aware indexes?
System Design ยท 1.2k views ยท upsert, idempotency, constraints
What is a subquery and what is a correlated subquery?
DSA ยท 1.2k views ยท subquery
How do you read an EXPLAIN query plan?
DSA ยท 1.1k views ยท explain
What is the difference between COUNT(*), COUNT(col), and COUNT(DISTINCT col)?
DSA ยท 971 views ยท count
Why might EXISTS outperform a JOIN for existence checks?
DSA ยท 970 views ยท exists, performance
EXPLAIN ANALYZE shows Seq Scan on a 10M-row table โ how do you diagnose and fix it?
System Design ยท 965 views ยท explain, seq-scan, index-scan
What are transaction isolation levels?
DSA ยท 924 views ยท isolation-levels
Hard
8 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
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
How do you solve gaps-and-islands problems in SQL?
DSA ยท 513 views ยท window-functions, gaps-and-islands
pgvector cosine similarity index in 2025-26 โ HNSW vs IVFFlat for semantic search at scale?
System Design ยท 467 views ยท pgvector, hnsw, cosine-search
What is a deadlock and how do you prevent it?
DSA ยท 366 views ยท deadlock
LATERAL vs Window Function vs Correlated Subquery for top-N per group โ which scales when?
System Design ยท 230 views ยท lateral-join, query-planning, performance
Seen a SQL question that is not here? Add it and help the next candidate.
Share a question