SQL interview questions
SQL Interview Questions
🔰 Basic SQL Interview Questions (For
Freshers)
1.
What
is SQL?
2.
What
is the difference between SQL and MySQL/SQL Server/Oracle?
3.
What
are the different types of SQL commands?
(DDL, DML, DCL, TCL, DQL)
4.
What
is the difference between DELETE, TRUNCATE, and DROP?
5.
What
is a primary key? Can a table have multiple primary keys?
6.
What
is a foreign key?
7.
What
is the difference between WHERE and HAVING?
8.
What
is a join? Name the types of joins.
9.
What
is normalization? Explain 1NF, 2NF, 3NF.
10.
What
is a constraint in SQL? Name a few.
💡 Intermediate SQL Interview Questions
1.
What
is the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL OUTER
JOIN?
2.
What
is a GROUP BY clause?
3.
What
is the use of ORDER BY clause?
4.
What
is a subquery? Explain correlated vs non-correlated subqueries.
5.
What
are indexes in SQL? How do they improve performance?
6.
What
is the difference between UNION and UNION ALL?
7.
What
is a view? How is it different from a table?
8.
What
is a stored procedure? How is it different from a function?
9.
What
is the difference between IS NULL, = NULL, and IS NOT NULL?
10.
What
is a trigger? When would you use one?
🧠 Advanced SQL Interview Questions
1.
How
do you find the second highest salary in a table?
2.
What
is a CTE (Common Table Expression)?
3.
How
would you optimize a slow-running query?
4.
What
is window function in SQL? Explain ROW_NUMBER(), RANK(), DENSE_RANK(), LEAD(),
LAG()
5.
What
is the difference between clustered and non-clustered index?
6.
How
do you handle duplicates in SQL?
7.
What
is a transaction? What are ACID properties?
8.
How
do you implement pagination in SQL?
9.
How
do you perform pivoting and unpivoting in SQL?
10.
What
are temporary tables and table variables?
🛠️ SQL Query Scenarios
1.
Write
a query to fetch duplicate records in a table.
2.
Write
a query to get the department with the highest number of employees.
3.
Write
a query to find employees who joined in the last 6 months.
4.
Write
a query to find the cumulative salary per department.
5.
Write
a query to transpose rows into columns.
6.
Write
a query to count the number of employees per department having more than 5
employees.
7.
Write
a query to get top 3 records per group (e.g., top 3 salaries per department).
8.
Write
a query to delete duplicate rows from a table.
9.
Write
a query to update a record based on a join.
10.
Write
a query to get all managers who don’t have any subordinates.
🔐 SQL Security and Admin
1.
What
are roles and permissions in SQL Server?
2.
What
is SQL injection? How can you prevent it?
3.
What
is the difference between GRANT, REVOKE, and DENY?
4.
How
do you take a backup and restore a database?
5.
What
is the difference between a login and a user in SQL Server?
No comments:
Post a Comment