Curated list of 100 essential SQL interview questions spanning beginner, intermediate, and advanced levels—all sourced from leading resources:
🔰 Beginner
- What is SQL?
- What is a database / DBMS / RDBMS?
- SQL vs MySQL vs NoSQL?
- SQL command categories ?
- CREATE vs ALTER vs DROP?
- INSERT, UPDATE, DELETE syntax?
- WHERE vs HAVING?
- GROUP BY vs ORDER BY?
- DISTINCT usage?
- UNION vs UNION ALL?
- INTERSECT and MINUS?
- LIKE and wildcards?
- NULL handling and COALESCE?
- CHAR vs VARCHAR vs TEXT?
- What are constraints ?
- Primary key vs Unique key?
- Foreign key and referential integrity?
- What is a view?
- What is a subquery?
- Correlated vs non‑correlated subquery?
- Aggregate functions ?
- ORDER BY clause?
- Basic operators: arithmetic, comparison, logical?
- What is a cursor?
- What is a trigger?
- Views/types ?
- SQL data types?
- BETWEEN and IN operators?
- CROSS JOIN vs INNER JOIN vs OUTER JOIN types?
- SELF JOIN?
- Pagination ?
- Creating tables like another?
- Pattern matching?
- SQL injection prevention?
- Referential integrity?
🧩 Intermediate
- What is a Common Table Expression (CTE)?
- What is a recursive CTE? Give a use case.
- Explain window (analytic) functions (e.g., ROW_NUMBER, RANK, DENSE_RANK).
- How would you calculate running totals or moving averages using window functions?
- What is the difference between CROSS JOIN, INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN?
- EXISTS vs IN vs JOIN — when should you use each?
- How do you calculate gaps in a sequence (e.g. missing IDs)?
- How do you rank items within groups—e.g., top 3 salaries per department?
- Handling NULLs in aggregation—how does COALESCE or ISNULL help?
- How to implement FULL OUTER JOIN in MySQL (which lacks native support)?
- Use of LAG() and LEAD() functions — what problems do they solve?
- What is a correlated subquery vs non‑correlated subquery? Provide examples.
- Difference between WHERE and HAVING clauses.
- Why use GROUP BY? Give an example.
- What is conditional aggregation and how does it help pivot data without PIVOT syntax?
- What are PIVOT and UNPIVOT operations?
- Explain dynamic SQL. Pros and cons?
- Compare temporary tables vs table variables (e.g., in SQL Server).
- What are stored procedures vs user-defined functions?
- What are triggers? When is AFTER INSERT trigger useful?
- Explain index types—clustered vs non‑clustered vs composite vs unique.
- What is index fragmentation? How do you rebuild or reorganize indexes?
- Describe how execution plans work and how EXPLAIN (or equivalent) is used.
- What is parameter sniffing and how can it affect performance?
- Explain implicit conversions and their impact on index usage.
- How to analyze wait statistics or blocking/deadlocks in a database?
- Explain isolation levels: Read Uncommitted, Read Committed, Repeatable Read, Serializable.
- When and why would you denormalize a database schema?
- Vertical vs horizontal partitioning (sharding)—what's the difference?
- What are indexed views or materialized views? How do they enhance performance?
- Difference between DELETE, TRUNCATE, and DROP (again focusing on transaction logging).
- What is the MERGE (UPSERT) statement and when to use it?
- How do you handle recursive/hierarchical data using CONNECT BY vs recursive CTEs?
- Explain CROSS APPLY vs OUTER APPLY (T‑SQL / SQL Server lateral join equivalents).
- What are statistics in SQL Server (or your RDBMS)? How do they affect the optimizer?
🚀 Advanced
- Transactions & ACID properties?
- Deadlocks, locks, and prevention?
- Stored Procedures vs Functions?
- Temporary tables vs Table variables?
- Dynamic SQL?
- MERGE statement?
- Materialized/indexed views?
- Query execution plan and EXPLAIN?
- Index types: clustered vs non-clustered vs unique vs composite?
- Index fragmentation & maintenance?
- Parameter sniffing in queries?
- Implicit conversions & performance?
- Wait statistics & blocking?
- Partitioning and sharding?
- Row-level security?
- Error handling ?
- Recursive/hierarchical queries using CONNECT BY or CTEs?
- Full-text search?
- CROSS APPLY vs OUTER APPLY?
- Statistics in SQL Server?
- Query plan memory grants?
- ETL staging tables and data pipelines?
- OLTP vs OLAP vs Data Warehousing schemas ?
- Surrogate keys vs natural keys?
- Database normalization forms ?
- Denormalization scenarios?
- Column vs row store and in-memory tables?
- Data lake & SQL integration ?
- Microservices and polyglot persistence?
- Internationalization, encryption, SQL security best practices?





