SQL
SQL
http://www.nityacloudtech.com/ @nityacloudtech
Nitya CloudTech Pvt Ltd.
List of some of the most popular SQL interview questions along with
sample answers that are commonly asked for data-related positions like
Data Analyst, Business Analyst, or Data Engineer roles:
Basic to Intermediate Questions
1. What is SQL, and what are its main functions?
o Answer: SQL (Structured Query Language) is a standard
http://www.nityacloudtech.com/ @nityacloudtech
Nitya CloudTech Pvt Ltd.
2. What is the difference between WHERE and HAVING clauses?
o Answer: WHERE filters rows before aggregation, whereas
a related column.
▪ INNER JOIN: Returns only matching rows from both
tables.
▪ LEFT JOIN (or LEFT OUTER JOIN): Returns all rows
from the left table and matched rows from the right table.
▪ RIGHT JOIN (or RIGHT OUTER JOIN): Returns all
rows from the right table and matched rows from the left
table.
▪ FULL JOIN (or FULL OUTER JOIN): Returns all rows
http://www.nityacloudtech.com/ @nityacloudtech
Nitya CloudTech Pvt Ltd.
▪ CROSS JOIN: Produces a Cartesian product of the two
tables.
http://www.nityacloudtech.com/ @nityacloudtech
Nitya CloudTech Pvt Ltd.
is unique.
▪ 2NF: Removes partial dependencies on the primary key.
attributes.
▪ BCNF: Stronger version of 3NF, requiring every
http://www.nityacloudtech.com/ @nityacloudtech
Nitya CloudTech Pvt Ltd.
uniqueness.
7. What is a foreign key?
o Answer: A foreign key is a column or set of columns in a table
http://www.nityacloudtech.com/ @nityacloudtech
Nitya CloudTech Pvt Ltd.
9. Explain the GROUP BY clause and its use with aggregate
functions.
o Answer: GROUP BY groups rows sharing a property so
http://www.nityacloudtech.com/ @nityacloudtech
Nitya CloudTech Pvt Ltd.
Advanced Questions
11. What is the difference between UNION and UNION ALL?
o Answer: UNION combines results of two queries and removes
duplicates, whereas UNION ALL includes duplicates.
http://www.nityacloudtech.com/ @nityacloudtech
Nitya CloudTech Pvt Ltd.
▪ Analyzing the query execution plan to identify bottlenecks.
http://www.nityacloudtech.com/ @nityacloudtech
Nitya CloudTech Pvt Ltd.
http://www.nityacloudtech.com/ @nityacloudtech
Nitya CloudTech Pvt Ltd.
16. How do you handle NULL values in SQL?
o Answer: Use IS NULL or IS NOT NULL to filter rows with
null values. Functions like COALESCE and IFNULL help
replace nulls with specified values.
http://www.nityacloudtech.com/ @nityacloudtech
Nitya CloudTech Pvt Ltd.
Or with a subquery:
SELECT salary FROM employees e1
WHERE (n - 1) = (
SELECT COUNT(DISTINCT salary) FROM
employees e2 WHERE e2.salary > e1.salary
);
http://www.nityacloudtech.com/ @nityacloudtech
Nitya CloudTech Pvt Ltd.
19. What are triggers in SQL?
o Answer: Triggers are automated actions executed before or
after events (INSERT, UPDATE, DELETE) on a table. They are
commonly used for auditing, data validation, and enforcing
business rules.
http://www.nityacloudtech.com/ @nityacloudtech
Nitya CloudTech Pvt Ltd.
http://www.nityacloudtech.com/ @nityacloudtech