SQL Interview Questions (Beginner to Intermediate)
Basic SQL
1. What is SQL and why is it used?
2. What are the different types of SQL statements?
3. How do you create a table in SQL? Give an example.
4. What is a primary key?
5. What is a foreign key?
6. How do you insert data into a table?
7. What is the difference between WHERE and HAVING clause?
8. How do you update existing records in a table?
9. How do you delete records from a table?
10. What is the use of the SELECT statement?
SQL Functions
1. What are aggregate functions in SQL? Give examples.
2. What is the difference between COUNT(*) and COUNT(column_name)?
3. Explain the use of GROUP BY clause with an example.
4. What are scalar functions? Give examples.
5. What is the difference between CHAR_LENGTH() and LENGTH()?
Joins and Subqueries
1. What are the different types of joins in SQL?
2. Explain INNER JOIN with an example.
3. What is the difference between LEFT JOIN and RIGHT JOIN?
4. What is a FULL OUTER JOIN?
5. What are subqueries? Provide an example.
6. What is the difference between correlated and non-correlated subqueries?
Advanced Queries
1. What is a view in SQL? How do you create one?
2. What is an index? How does it improve query performance?
3. What is normalization? Explain different normal forms.
4. What is denormalization and when is it used?
5. Explain the concept of transactions in SQL.
6. What are ACID properties in a database transaction?
7. How do you use CASE statements in SQL?
8. What is a CTE (Common Table Expression)?