0% found this document useful (0 votes)
4 views2 pages

SQL Interview Questions CheatSheet

The document outlines the top 10 frequently asked SQL interview questions, covering topics such as the differences between DELETE, TRUNCATE, and DROP, types of JOINs, and the use of GROUP BY and HAVING. It also explains normalization, ACID properties, and how to find duplicates in a table. Additionally, it includes SQL queries for specific tasks like finding the second highest salary and joining two tables.

Uploaded by

sri191969
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

SQL Interview Questions CheatSheet

The document outlines the top 10 frequently asked SQL interview questions, covering topics such as the differences between DELETE, TRUNCATE, and DROP, types of JOINs, and the use of GROUP BY and HAVING. It also explains normalization, ACID properties, and how to find duplicates in a table. Additionally, it includes SQL queries for specific tasks like finding the second highest salary and joining two tables.

Uploaded by

sri191969
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Top 10 Frequently Asked SQL Interview Questions

1. Difference between DELETE, TRUNCATE, and DROP


DELETE: Deletes rows with condition, rollback possible, structure remains.
TRUNCATE: Deletes all rows quickly, no rollback, structure remains.
DROP: Deletes table entirely, no rollback, structure removed.

2. Types of JOIN
INNER JOIN: Matching rows.
LEFT JOIN: All left + matched right.
RIGHT JOIN: All right + matched left.
FULL OUTER JOIN: All from both.
CROSS JOIN: All combinations.

3. Query to Find Second Highest Salary


SELECT MAX(salary) FROM Employees WHERE salary < (SELECT MAX(salary) FROM Employees);

4. Use of GROUP BY and HAVING


GROUP BY: Groups rows.
HAVING: Filters groups after grouping.

5. Difference between WHERE and HAVING


WHERE: Filters rows before grouping.
HAVING: Filters after GROUP BY.

6. What is Normalization?
Process of structuring data to reduce redundancy.
1NF: No repeating groups
2NF: No partial dependencies
3NF: No transitive dependencies

7. ACID Properties
A: Atomicity All or nothing
C: Consistency Valid state
I: Isolation Transactions dont interfere
D: Durability Changes persist

8. Finding Duplicates in a Table


SELECT column, COUNT(*) FROM table GROUP BY column HAVING COUNT(*) > 1;

9. Join Between Two Tables


SELECT A.name, B.salary FROM Employees A JOIN Salaries B ON A.emp_id = B.emp_id;
10. Difference Between UNION and UNION ALL
UNION: Removes duplicates, slower.
UNION ALL: Keeps all, faster.

You might also like