0% found this document useful (0 votes)
9 views5 pages

FFFF

The document outlines SQL interview questions for data analytics, covering essential concepts such as SQL importance, JOIN types, data manipulation, and aggregate functions. It provides examples for calculating median, running totals, and year-over-year growth, as well as explanations of normalization, data cleaning, and debugging techniques. The content is designed to prepare candidates for SQL-related roles in data analytics for 2025.

Uploaded by

debadritadas0
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)
9 views5 pages

FFFF

The document outlines SQL interview questions for data analytics, covering essential concepts such as SQL importance, JOIN types, data manipulation, and aggregate functions. It provides examples for calculating median, running totals, and year-over-year growth, as well as explanations of normalization, data cleaning, and debugging techniques. The content is designed to prepare candidates for SQL-related roles in data analytics for 2025.

Uploaded by

debadritadas0
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/ 5

SQL INTERVIEW QUESTIONS 2025​

FOR DATA ANALYTICS


INSTRUCTOR: Ms.SHALINI RAVI

1. What is SQL and why is it important in data analytics?

SQL is used to extract, manipulate, and analyze data stored in relational


databases – a core skill for data analysts.

2. What is the difference between INNER JOIN and LEFT JOIN?

●​ INNER JOIN: Returns only matching records.​

●​ LEFT JOIN: Returns all from the left table, plus matches from the
right.

3. How do you remove duplicates from a table?

SELECT DISTINCT column1, column2 FROM table_name;

4. How do you calculate the median in SQL?

Using window functions and CTEs, depending on the database system:

-- Example (PostgreSQL)

SELECT percentile_cont(0.5) WITHIN GROUP (ORDER BY column)


FROM table;

5. Explain window functions with an example.

Window functions perform calculations across a set of rows related to the


current row.

SELECT name, salary, RANK() OVER (ORDER BY salary DESC) FROM


employees;

1
6. What is the difference between GROUP BY and PARTITION
BY?

●​ GROUP BY: Aggregates data into groups.​

●​ PARTITION BY: Used in window functions to divide data without


collapsing rows.

7. How do you find the top 3 products by sales?

SELECT product, SUM(sales) as total_sales

FROM orders

GROUP BY product

ORDER BY total_sales DESC

LIMIT 3;

8. How do you handle NULL values in SQL?

Using IS NULL, IS NOT NULL, or functions like COALESCE().

9. What is a CTE and why use it?

CTE (Common Table Expression) improves readability and modularizes


complex queries using WITH.

10. How do you calculate the running total?

SELECT date, sales,

SUM(sales) OVER (ORDER BY date) AS running_total

FROM sales_data;

2
11. How can you identify trends over time?

By aggregating data using GROUP BY with date functions:

SELECT DATE_TRUNC('month', sale_date) AS month, SUM(sales)

FROM orders

GROUP BY month;

12. What is data granularity and why does it matter in analytics?

Granularity refers to the level of detail in data – finer granularity gives


more detail.

13. How do you calculate year-over-year growth in SQL?

Using LAG() window function:

SELECT year, sales,

LAG(sales) OVER (ORDER BY year) AS previous_year_sales,

(sales - LAG(sales) OVER (ORDER BY year)) / LAG(sales) OVER (ORDER


BY year) AS yoy_growth

FROM sales_data;

14. What are aggregate functions in SQL?

Functions like SUM(), AVG(), COUNT(), MIN(), and MAX() used to


summarize data.

15. What is a correlated subquery?

A subquery that refers to columns in the outer query.

3
16. How do you perform data cleaning in SQL?

Using functions like TRIM(), REPLACE(), NULLIF(), and filtering


conditions.

17. What is normalization and denormalization?

●​ Normalization: Reduces redundancy by organizing data into


multiple tables.​

●​ Denormalization: Combines tables to speed up queries, useful in


analytics.

18. How do you pivot data in SQL?

Using CASE WHEN statements or PIVOT operator (if supported):

SELECT

employee,

SUM(CASE WHEN month = 'Jan' THEN sales ELSE 0 END) AS


Jan_Sales,

...

FROM sales_data

GROUP BY employee;

19. How do you rank rows in SQL without skipping numbers on


ties?

Using DENSE_RANK():

SELECT name, DENSE_RANK() OVER (ORDER BY score DESC) FROM


results;

4
20. How do you debug a complex SQL query?

Break into smaller parts

Use CTEs

Test subqueries separately

Use LIMIT to check output

Validate joins and filters

You might also like