@dixit-prashant
10
SQL Interview
Questions you
must prepare as a
Data Analyst
@dixit-prashant
When I started learning SQL, I thought
memorizing syntax was enough...
But in interviews, they don’t just ask you
to write queries.
They want to know if you understand the
concepts behind them.
That's when I started breaking SQL
topics into bite-sized answers.
just like this 👇
1
@dixit-prashant
1. What is SQL and why is it
important?
SQL stands for Structured Query
Language.
Used to manage and query relational
databases.
Essential for extracting insights from
large data.
Core skill for data analysts, BI, and
reporting tasks.
1
@dixit-prashant
2. Difference between WHERE and
HAVING?
WHERE filters rows before
aggregation.
HAVING filters after
grouping/aggregates.
Use WHERE with raw data filters.
Use HAVING with conditions on
SUM(), AVG(), etc.
2
@dixit-prashant
3. INNER JOIN vs LEFT JOIN?
INNER JOIN returns only matching
rows.
LEFT JOIN returns all from left,
matched from right.
Use LEFT JOIN to keep unmatched
left rows.
NULL appears where no right table
match exists.
3
@dixit-prashant
4. Primary Key vs Foreign Key?
Primary Key uniquely identifies each
row.
Foreign Key links two tables
together.
Primary Key = unique + not null.
Foreign Key = ensures referential
integrity.
4
@dixit-prashant
5. What are aggregate functions?
Perform operations on multiple rows.
Examples: SUM(), AVG(), COUNT(),
MAX().
Often used with GROUP BY.
Return one result per group or
dataset.
5
@dixit-prashant
6. What is a subquery?
A query inside another query.
Used to calculate intermediate
results.
Can be used in SELECT, FROM, or
WHERE.
Helps break down complex queries.
6
@dixit-prashant
7. DELETE vs TRUNCATE vs DROP?
DELETE: removes specific rows,
reversible.
TRUNCATE: removes all rows,
faster, not reversible.
DROP: removes entire table
structure.
DELETE logs row-by-row;
TRUNCATE doesn’t.
7
@dixit-prashant
8. What is the use of GROUP BY?
Groups data based on one or more
columns.
Works with aggregate functions.
Used to summarize or segment data.
Must include non-aggregated
columns in GROUP BY.
8
@dixit-prashant
9. How do you handle NULLs?
Use IS NULL or IS NOT NULL to
filter.
Use COALESCE() or IFNULL() to
replace.
NULL ≠ 0 or empty string.
Can impact joins, grouping, and
comparisons.
9
@dixit-prashant
10. What are window functions?
Perform calculations across a
window of rows.
Do not collapse rows like
aggregates.
Examples: RANK(),
ROW_NUMBER(), LEAD().
Useful for rankings, trends, and
comparisons.
10
@dixit-prashant
💡 Pro Tip: Understand the why behind
every query.
📩 Want me to break down answers to
these questions in detail?
SHARE SAVE LIKE
YOUR FOR THIS
THOUGHTS LATER POST
11