0% found this document useful (0 votes)
5 views7 pages

SQL Interview Questions

The document provides a comprehensive list of SQL interview questions tailored for Data Analysts, covering topics such as finding duplicates, different types of joins, query optimization, window functions, and more. Each question includes a mixed language explanation, a concise interview answer, an example SQL query, and its application in data analysis. This resource is aimed at helping candidates prepare effectively for SQL-related interviews.
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)
5 views7 pages

SQL Interview Questions

The document provides a comprehensive list of SQL interview questions tailored for Data Analysts, covering topics such as finding duplicates, different types of joins, query optimization, window functions, and more. Each question includes a mixed language explanation, a concise interview answer, an example SQL query, and its application in data analysis. This resource is aimed at helping candidates prepare effectively for SQL-related interviews.
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

Perfect 👍

Below are ALL SQL interview questions from the image, each explained clearly for Data
Analyst interviews, exactly in the format you asked.

1️⃣ How do you find duplicate records in a table?


🔹 Mixed English + Telugu Explanation (20–30 words)
SQL lo duplicate records ante same values multiple rows lo undadam. GROUP BY +
HAVING COUNT(*) > 1 use chesi duplicates ni identify cheyyachu.

🔹 Interview Answer (20–30 words)


Duplicate records are identified by grouping rows on specific columns and using HAVING
COUNT(*) > 1 to find repeated values in a table.

🔹 Example
sql Copy code

SELECT email, COUNT(*)


FROM users
GROUP BY email
HAVING COUNT(*) > 1;

🔹 Use in Data Analysis


Data cleaning phase lo duplicates remove cheyadaniki, accurate reporting kosam,
customer data quality improve cheyadaniki duplicates check chestaru.

2️⃣ Difference between INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL
OUTER JOIN

🔹 Mixed English + Telugu Explanation


JOINs ante multiple tables ni common column meeda combine cheyadam. INNER
common rows, LEFT left table complete, RIGHT right table complete, FULL anni rows return
chestayi.

🔹 Interview Answer
INNER JOIN returns matching rows, LEFT JOIN returns all left table rows, RIGHT JOIN
returns all right table rows, FULL OUTER JOIN returns all rows from both tables.

🔹 Example
sql Copy code

SELECT *
FROM orders o
LEFT JOIN customers c
ON o.customer_id = c.customer_id;

🔹 Use in Data Analysis


Multiple data sources ni combine cheyadaniki, missing data analysis kosam, customer-
order relationships analyze cheyadaniki joins use chestaru.

3️⃣ How do you optimize a slow-running query?


🔹 Mixed English + Telugu Explanation
Slow query ante performance issue. Indexes add cheyadam, unnecessary columns remove
cheyadam, WHERE clause optimize cheyadam valla query speed improve avuthundi.

🔹 Interview Answer
Query optimization includes adding indexes, avoiding SELECT *, using proper WHERE
conditions, analyzing execution plans, and reducing unnecessary joins.

🔹 Example
sql Copy code

CREATE INDEX idx_order_date ON orders(order_date);

🔹 Use in Data Analysis


Large datasets lo fast results kavali kabatti optimized queries dashboards, reports, and
real-time analytics lo important.

4️⃣ What are window functions and how are they used?
🔹 Mixed English + Telugu Explanation
Window functions row-level calculations chestayi without grouping rows. Ranking, running
totals, moving averages calculate cheyadaniki use avuthayi.

🔹 Interview Answer
Window functions perform calculations across related rows using OVER() clause without
collapsing rows, useful for ranking, cumulative sums, and trend analysis.

🔹 Example
sql Copy code

SELECT date,
SUM(sales) OVER (ORDER BY date) AS running_total
FROM sales;

🔹 Use in Data Analysis


Time-series analysis, growth trends, rankings, performance comparison dashboards lo
window functions extensively use chestaru.

5️⃣ What are Common Table Expressions (CTEs)?


🔹 Mixed English + Telugu Explanation
CTE ante temporary named result set. Complex queries ni readable ga divide cheyadaniki
WITH keyword use chestaru.

🔹 Interview Answer
CTEs improve readability and maintainability by breaking complex SQL queries into logical,
reusable blocks using the WITH clause.

🔹 Example
sql Copy code

WITH sales_cte AS (
SELECT region, SUM(sales) total_sales
FROM sales
GROUP BY region
)
SELECT * FROM sales_cte;

🔹 Use in Data Analysis


Complex transformations, step-by-step logic, debugging easy cheyadaniki data analysts
CTEs prefer chestaru.

6️⃣ How do you filter results using a subquery?


🔹 Mixed English + Telugu Explanation
Subquery ante query inside query. One table results ni base chesi another table ni filter
cheyadaniki use chestaru.

🔹 Interview Answer
Subqueries allow filtering records by comparing values with results returned from another
query, often used with IN, EXISTS, or comparison operators.

🔹 Example
sql Copy code

SELECT *
FROM employees
WHERE department_id IN (
SELECT department_id FROM departments WHERE location = 'Hyderabad'
);

🔹 Use in Data Analysis


Conditional filtering, advanced business logic, dependent calculations cheyadaniki
subqueries use chestaru.

7️⃣ How do you calculate a rolling 7-day average?


🔹 Mixed English + Telugu Explanation
Rolling average ante current day + previous days average. Window function with ROWS
BETWEEN clause use chesi calculate chestaru.
🔹 Interview Answer
A rolling 7-day average is calculated using window functions with ORDER BY and ROWS
BETWEEN 6 PRECEDING AND CURRENT ROW.

🔹 Example
sql Copy code

SELECT date,
AVG(sales) OVER (
ORDER BY date
ROWS BETWEEN 6 PRECEDING AND CURRENT ROW
) AS avg_7_days
FROM sales;

🔹 Use in Data Analysis


Trend smoothing, seasonal analysis, sales performance tracking lo rolling averages very
useful.

8️⃣ Difference between WHERE and HAVING


🔹 Mixed English + Telugu Explanation
WHERE rows filter chestundi before grouping. HAVING aggregated results ni filter
chestundi after GROUP BY.

🔹 Interview Answer
WHERE filters individual rows before aggregation, while HAVING filters grouped results
after aggregate functions are applied.

🔹 Example
sql Copy code

SELECT department, COUNT(*)


FROM employees
WHERE salary > 30000
GROUP BY department
HAVING COUNT(*) > 5;
🔹 Use in Data Analysis
Row-level filtering and aggregate-level insights separate ga handle cheyadaniki WHERE &
HAVING use chestaru.

9️⃣ How do you pivot (transpose) a table in SQL?


🔹 Mixed English + Telugu Explanation
Pivot ante rows ni columns ga convert cheyadam. CASE statements or PIVOT function use
chesi data reshape chestaru.

🔹 Interview Answer
Pivoting transforms row data into columns using CASE expressions or PIVOT functions,
enabling summarized and comparative reporting.

🔹 Example
sql Copy code

SELECT
SUM(CASE WHEN month='Jan' THEN sales END) AS Jan,
SUM(CASE WHEN month='Feb' THEN sales END) AS Feb
FROM sales;

🔹 Use in Data Analysis


Cross-tab reports, dashboards, month-wise or category-wise comparison cheyadaniki
pivot use chestaru.

🔟 How do indexes improve query performance?


🔹 Mixed English + Telugu Explanation
Index ante book index laanti structure. Data fast ga search cheyadaniki help chestundi but
insert/update slow avvachu.

🔹 Interview Answer
Indexes speed up data retrieval by reducing full table scans, especially useful for large
tables and frequently filtered columns.
🔹 Example
sql Copy code

CREATE INDEX idx_email ON users(email);

🔹 Use in Data Analysis


Large datasets lo filtering, joining, reporting speed improve cheyadaniki indexes essential.

🔥 If you want:
PDF format
PowerPoint slides
Mock interview Q&A
Practice SQL questions with answers

Just tell me 👍

You might also like