SQL Interview Questions
Joins, GROUP BY, subqueries, window functions, CTEs and classic query-writing problems.
61 questions
Popular Searches
1. How Does the SELECT Statement Work in SQL?
easyQueries 6 mins2. How Does the WHERE Clause Work in SQL?
easyQueries 6 mins3. INNER JOIN vs LEFT JOIN in SQL
mediumJoins 7 mins4. How Does GROUP BY Work in SQL?
mediumAggregation 6 mins5. HAVING vs WHERE in SQL
mediumAggregation 6 mins6. What are Aggregate Functions in SQL?
easyAggregation 5 mins7. What Does the DISTINCT Keyword Do in SQL?
easyQueries 5 mins8. What are Subqueries in SQL?
mediumSubqueries 7 mins9. What is a Correlated Subquery in SQL?
hardSubqueries 8 mins10. UNION vs UNION ALL in SQL
easyQueries 6 mins11. What are Window Functions in SQL?
hardAdvanced 8 mins12. RANK vs DENSE_RANK vs ROW_NUMBER in SQL
hardAdvanced 7 mins13. What are Common Table Expressions (CTEs) in SQL?
mediumAdvanced 6 mins14. How Does the CASE Statement Work in SQL?
easyQueries 5 mins15. EXISTS vs IN in SQL
mediumSubqueries 6 mins16. What is a Self Join in SQL?
mediumJoins 6 mins17. How Do You Find the Second Highest Salary in SQL?
mediumProblems 6 mins18. How Do You Find Duplicate Records in SQL?
mediumProblems 6 mins19. How Do You Delete Duplicate Rows in SQL?
hardProblems 6 mins20. How Do LIMIT and OFFSET Work in SQL?
easyQueries 5 mins21. How Does the LIKE Operator Work in SQL?
easyQueries 5 mins22. How Do You Handle NULL Values in SQL?
mediumQueries 6 mins23. How Do You Find the Nth Highest Salary in SQL?
hardProblems 8 mins24. How Do You UPDATE with a JOIN in SQL?
mediumQueries 7 mins25. What are Date Functions in SQL?
mediumFunctions 6 mins26. What are String Functions in SQL?
easyFunctions 5 mins27. How Do You Pivot Data in SQL?
hardAdvanced 7 mins28. How Do COALESCE and NULLIF Work in SQL?
mediumFunctions 6 mins29. What is a CROSS JOIN in SQL?
mediumJoins 6 mins30. How Does ORDER BY Work in SQL?
easyQueries 5 mins31. What is a JOIN?
easyJoins 5 mins32. Explain Types of SQL Joins
easyJoins 6 mins33. Difference Between WHERE and HAVING?
easyFiltering & Aggregation 5 mins34. What is Normalization?
easyDatabase Design 6 mins35. What is an Index?
easyPerformance 6 mins36. What is a Primary Key vs Foreign Key?
easyDatabase Design 5 mins37. What is a Subquery?
mediumAdvanced Queries 7 mins38. What is a CTE?
mediumAdvanced Queries 7 mins39. What Is the Difference Between UNION and UNION ALL?
mediumSet Operators 5 mins40. What Is a View in SQL?
mediumDatabase Objects 5 mins41. What Is the Difference Between a Clustered and a Non-Clustered Index?
mediumIndexing 6 mins42. What Is a Transaction in SQL?
mediumTransactions 6 mins43. What Is the Difference Between GROUP BY and ORDER BY?
hardQuery Fundamentals 6 mins44. What Is the Difference Between CHAR and VARCHAR?
hardData Types 6 mins45. What Is Denormalization in Database Design?
hardDatabase Design 6 mins46. How Do You Find the Second Highest Salary in SQL?
hardQuery Techniques 7 mins47. How Do You Read an Execution Plan and Work Out Why the Optimiser Chose a Scan Instead of an Index Seek?
hardQuery Optimisation 9 mins48. How Does Index Selectivity Work, and How Do You Decide the Column Order in a Composite Index?
hardIndexing 9 mins49. What Is a SARGable Predicate, and Which Common WHERE Clauses Silently Disable Index Use?
hardQuery Optimisation 9 mins50. How Do Window Function Frame Clauses Work, and Why Does ROWS Differ From RANGE?
hardWindow Functions 9 mins51. How Does a Recursive CTE Work, and How Do You Stop One Running Forever on Cyclic Data?
hardCommon Table Expressions 9 mins52. When Would You Use EXISTS Rather Than a Join or a Correlated Subquery, and How Do They Differ in Practice?
hardSubqueries and Joins 9 mins53. How Do NULLs Behave in Aggregates, Joins and NOT IN, and Where Do They Silently Change Results?
hardNULL Semantics 9 mins54. What Anomalies Does Each Transaction Isolation Level Permit, and How Do You Choose One?
hardTransactions and Concurrency 10 mins55. How Do You Diagnose a Deadlock, and What Is Lock Escalation?
hardTransactions and Concurrency 10 mins56. Why Does a MERGE or Check-Then-Insert Upsert Race Under Concurrency, and How Do You Make It Safe?
hardTransactions and Concurrency 9 mins57. Why Does OFFSET Pagination Get Slower on Later Pages, and How Does Keyset Pagination Fix It?
hardQuery Optimisation 9 mins58. A Query Was Fast Yesterday and Slow Today With No Code Change — How Do Statistics and Parameter Sniffing Explain That?
hardQuery Optimisation 10 mins59. When Does Table Partitioning Actually Help, and What Stops Partition Pruning From Working?
hardPhysical Design 10 mins60. How Do You Add a Column, an Index or a Constraint to a Large Live Table Without Downtime?
hardSchema Migration 10 mins61. How Do You Delete or Backfill Millions of Rows Without Stalling Production?
hardData Operations 10 mins