← 30 Days of SQL
Day 27 / 30Interview Prep

SQL for Data Analyst Interviews — Frequently Asked Questions

A curated set of questions that are asked repeatedly in data analyst interviews at companies hiring in Delhi NCR — across all difficulty levels.

1
Easy

Write a single query to find total, average, max and min salary in one result.

SQL Answer
SELECT
  COUNT(*) AS headcount,
  SUM(salary) AS total_salary,
  ROUND(AVG(salary), 2) AS avg_salary,
  MAX(salary) AS highest,
  MIN(salary) AS lowest
FROM employees;
💡

Interviewers like this to test whether you know multiple aggregates can go in the same SELECT. Always alias your columns for readable output.

2
Medium

Find employees whose salary is above average but below the maximum.

SQL Answer
SELECT name, salary
FROM employees
WHERE salary > (SELECT AVG(salary) FROM employees)
  AND salary < (SELECT MAX(salary) FROM employees)
ORDER BY salary DESC;
💡

Two scalar subqueries in one WHERE clause. Tests whether you can combine subqueries with AND. A common way to identify mid-to-high performers.

3
Hard

Find the 3rd highest salary without using LIMIT/TOP.

SQL Answer
SELECT MIN(salary) AS third_highest
FROM (
  SELECT DISTINCT salary
  FROM employees
  ORDER BY salary DESC
  LIMIT 3
) top3;

-- Without LIMIT at all:
SELECT MAX(salary) AS third_highest
FROM employees
WHERE salary NOT IN (
  SELECT DISTINCT salary FROM employees
  ORDER BY salary DESC LIMIT 2
);
💡

Classic trick question. The first approach uses LIMIT inside a subquery. The second uses NOT IN to exclude top 2 then finds MAX of what's left.

4
Medium

What is the difference between DELETE, TRUNCATE and DROP?

SQL Answer
-- DELETE: removes specific rows, can use WHERE, logs each row, rollback possible
DELETE FROM employees WHERE department = 'Old Dept';

-- TRUNCATE: removes ALL rows fast, cannot use WHERE, minimal logging, faster
TRUNCATE TABLE temp_data;

-- DROP: removes the table itself (structure + data + indexes)
DROP TABLE temp_data;
💡

DELETE is DML (reversible in a transaction). TRUNCATE is DDL (fast, not row-by-row logged). DROP destroys the table. Know all three — common theory question.

5
Medium

Explain the execution order of SQL clauses.

SQL Answer
-- SQL execution order (not writing order):
-- 1. FROM (and JOINs) — identify source tables
-- 2. WHERE — filter rows
-- 3. GROUP BY — group remaining rows
-- 4. HAVING — filter groups
-- 5. SELECT — choose columns and expressions
-- 6. DISTINCT — remove duplicates
-- 7. ORDER BY — sort result
-- 8. LIMIT / TOP — restrict output rows
💡

This explains WHY you cannot use a SELECT alias in WHERE (WHERE runs before SELECT) but CAN use it in ORDER BY (ORDER BY runs after SELECT). A favourite interview theory question.

EVIKA ACADEMY · SQL FOR DATA ANALYTICS

Want to master SQL with live practice?

Join our SQL for Data Analytics course — live classes in Noida and online across India.

Book Free Demo Class →
← PREVIOUSDay 26: Interview Question Patterns — Find Duplicates, Gaps, IslandsNEXT →Day 28: SQL Practice: 10 Mixed Questions
Best Data Analytics Course in Noida Delhi NCR | EVIKA ACADEMY