Below are some sample SQL interview questions categorized into basic, intermediate, and advanced levels for a fresher candidate:
Basic SQL Interview Questions:
1. What is SQL and why is it important?
2. Explain the difference between SQL and MySQL.
3. What are the basic SQL commands?
4. How do you retrieve all columns from a table named "employees"?
5. Explain the SELECT statement in SQL.
6. What is a primary key?
7. Define the term normalization in the context of databases.
8. How do you insert data into a table?
9. Explain the concept of foreign keys.
10. What is the purpose of the WHERE clause in SQL?
Intermediate SQL Interview Questions:
11. Write a SQL query to find the second-highest salary from an "employees" table.
12. Explain the difference between INNER JOIN and LEFT JOIN.
13. What is a subquery? Provide an example.
14. How can you prevent SQL injection in your queries?
15. Write a query to count the number of rows in a table.
16. Explain the concept of indexing in databases.
17. What is the purpose of the GROUP BY clause?
18. Write a query to retrieve data from multiple tables using JOIN.
19. Explain the ACID properties in the context of databases.
20. How do you update data in a table using the UPDATE statement?
Advanced SQL Interview Questions:
21. What is a stored procedure? How is it different from a function?
22. Write a query to find the third-highest salary without using the LIMIT clause.
23. Explain the concept of a materialized view.
24. What is the difference between UNION and UNION ALL in SQL?
25. Write a query to calculate the cumulative sum of a column.
26. How do you optimize a SQL query for better performance?
27. Explain the use of the HAVING clause.
28. What are window functions in SQL? Provide an example.
29. Describe the purpose of triggers in a database.
30. Explain the differences between NoSQL and SQL databases.
Comments