Antony Raj Victor Data Analyst
🚀 Top SQL
Interview
Questions and
Solutions 🚀
PART 1
Antony Raj Victor Data Analyst
Q: What is the difference between UNION
and UNION ALL?
SOLUTION:
UNION: Combines results from two
queries but removes duplicate rows.
UNION ALL: Combines results from
two queries, including duplicates.
Swipe for more
Antony Raj Victor Data Analyst
Q: How do you find duplicate rows in a
table?
SOLUTION:
Use the GROUP BY clause to group the
rows, and the HAVING clause to filter
groups with more than one occurrence.
SELECT column_name, COUNT(*)
FROM table_name
GROUP BY column_name
HAVING COUNT(*) > 1;
Swipe for more
Antony Raj Victor Data Analyst
Q: What is the difference between DELETE,
TRUNCATE, and DROP?
SOLUTION:
DELETE: Removes rows from a table,
but the structure remains. Can be
rolled back.
TRUNCATE: Removes all rows from a
table and cannot be rolled back, but
the structure remains.
DROP: Deletes the table and its
structure completely.
Swipe for more
Antony Raj Victor Data Analyst
Q: What is normalization in SQL?
SOLUTION:
Normalization is the process of organizing
data to reduce redundancy and improve
data integrity. There are several normal
forms, from 1NF to 5NF, each aiming to
minimize data duplication and make the
database more efficient.
Example: Splitting a customer’s contact info
into separate tables for address and phone
numbers.
Swipe for more
Antony Raj Victor Data Analyst
Q: What are the different types of JOINs in
SQL?
SOLUTION:
INNER JOIN – Returns matching rows
from both tables.
LEFT JOIN – Returns all rows from the
left table and matching rows from the
right table.
RIGHT JOIN – Returns all rows from the
right table and matching rows from the
left table.
FULL JOIN – Returns all rows when
there’s a match in either left or right
table.
Swipe for more
Antony Raj Victor Data Analyst
Q: What is a subquery and when would you
use it?
SOLUTION:
A subquery is a query nested inside another
query. It's used for:
Returning a single value to be used in the
main query.
Filtering results in the main query with
conditions based on another query.
SELECT * FROM employees
WHERE salary > (SELECT AVG(salary)
FROM employees);
Swipe for more
Antony Raj Victor Data Analyst
Practice Makes
Perfect! 💪
SQL interviews can be tough, but with
preparation, you’ve got this!
Keep practicing these questions and
stay confident.
🍀
Good luck!