TGViewer
Data Analytics Data Analytics @sqlspecialist ยท 111K subscribers
Post #2783 5.94K
๐Ÿš€ Data Analyst Interview Questions with Answers โ€” Part 2

๐Ÿ“Š SQL & Databases

11. What is SQL and why is it critical for data analysts?
SQL (Structured Query Language) is used to communicate with databases. It helps analysts retrieve, filter, clean, and analyze data efficiently.

It is critical because most business data is stored in databases, and SQL allows analysts to extract insights directly from large datasets.

12. How do "SELECT", "WHERE", "ORDER BY", and "LIMIT" work?
โœ… "SELECT" โ†’ Used to choose columns from a table

SELECT name, salary FROM employees;

โœ… "WHERE" โ†’ Filters rows based on conditions

SELECT FROM employees
WHERE salary > 50000;

โœ… "ORDER BY" โ†’ Sorts data ascending or descending

SELECT FROM employees
ORDER BY salary DESC;

โœ… "LIMIT" โ†’ Restricts the number of rows returned

SELECT FROM employees
LIMIT 5;

13. How do you join two tables ("INNER", "LEFT", "RIGHT", "FULL" joins)?

๐Ÿ“Œ "INNER JOIN" โ†’ Returns matching records from both tables

๐Ÿ“Œ "LEFT JOIN" โ†’ Returns all records from the left table + matching rows from the right table

๐Ÿ“Œ "RIGHT JOIN" โ†’ Returns all records from the right table + matching rows from the left table

๐Ÿ“Œ "FULL JOIN" โ†’ Returns all matching and non-matching records from both tables

Example:
SELECT customers.name, orders.order_id
FROM customers
INNER JOIN orders
ON customers.id = orders.customer_id;

14. How do "GROUP BY" and aggregate functions work?

Aggregate functions summarize data.

Common functions:
โœ”๏ธ "SUM()"
โœ”๏ธ "AVG()"
โœ”๏ธ "COUNT()"
โœ”๏ธ "MAX()"
โœ”๏ธ "MIN()"

Example:
SELECT department, AVG(salary)
FROM employees
GROUP BY department;

This groups employees by department and calculates average salary.

15. How do you write subqueries and CTEs?
๐Ÿ“Œ Subquery โ†’ Query inside another query

SELECT name
FROM employees
WHERE salary > (
SELECT AVG(salary)
FROM employees
);

๐Ÿ“Œ CTE (Common Table Expression) โ†’ Temporary result set that improves readability

WITH high_salary AS (
SELECT
FROM employees
WHERE salary > 50000
)
SELECT FROM high_salary;

16. How do you calculate running totals or rolling averages with window functions?

Window functions perform calculations across rows without collapsing data.

Example โ€” Running Total:
SELECT order_date,
sales,
SUM(sales) OVER (ORDER BY order_date) AS running_total
FROM orders;
Example โ€” Rolling Average:
SELECT order_date,
AVG(sales) OVER (
ORDER BY order_date
ROWS BETWEEN 2 PRECEDING AND CURRENT ROW
) AS rolling_avg
FROM orders;

17. How do you clean and filter data directly in SQL?

Data cleaning in SQL includes:
โœ”๏ธ Removing duplicates
โœ”๏ธ Handling NULL values
โœ”๏ธ Standardizing text
โœ”๏ธ Filtering invalid rows

Example:
SELECT TRIM(LOWER(name))
FROM customers
WHERE email IS NOT NULL;

18. How do you handle duplicates and NULL values in SQL?

โœ… Remove duplicates using "DISTINCT"
SELECT DISTINCT city
FROM customers;

โœ… Find NULL values
SELECT
FROM employees
WHERE salary IS NULL;

โœ… Replace NULL values
SELECT COALESCE(salary, 0)
FROM employees;

19. How do you optimize a slow query?
Common optimization techniques:

๐Ÿš€ Use indexes
๐Ÿš€ Avoid unnecessary columns in "SELECT *"
๐Ÿš€ Filter data early using "WHERE"
๐Ÿš€ Optimize joins
๐Ÿš€ Use proper aggregations
๐Ÿš€ Analyze execution plans

Efficient queries improve performance and reduce database load.

20. How do you design a simple schema for a business domain?

A schema organizes data into related tables.

Example for an e-commerce business:
๐Ÿ“Œ "Customers" table
๐Ÿ“Œ "Orders" table
๐Ÿ“Œ "Products" table
๐Ÿ“Œ "Payments" table

Relationships are created using primary keys and foreign keys to maintain data integrity.

๐Ÿš€ Double Tap โค๏ธ For Part-3
  • โค 24
More from @sqlspecialist
  1. Oct 9, 2026โ€œHere, the data is sorted by the second column in descending order and the first five rowsโ€ฆ
  2. Oct 9, 2026๐Ÿ“Š Data Analyst Interview Series โ€” Part 6 Guys, let's continue our Data Analyst Interviewโ€ฆ
  3. Oct 9, 2026๐Ÿ‡ฎ๐Ÿ‡ณ ๐—š๐—ข๐—ฉ๐—˜๐—ฅ๐—ก๐— ๐—˜๐—ก๐—ง ๐—ข๐—™ ๐—œ๐—ก๐——๐—œ๐—” โ€” ๐—”๐—œ๐—–๐—ง๐—˜ ๐—œ๐—ก๐—ง๐—˜๐—ฅ๐—ก๐—ฆ๐—›๐—œ๐—ฃ๐—ฆ ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ ๐Ÿš€โ€ฆ
  4. Oct 8, 2026๐ŸŽ“ ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜€๐—ผ๐—ณ๐˜ ๐—™๐—ฅ๐—˜๐—˜ ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ๐˜€ ๐˜„๐—ถ๐˜๐—ต ๐—–๐—ฒ๐—ฟ๐˜๐—ถ๐—ณ๐—ถ๐—ฐ๐—ฎ๐˜๐—ฒ๐˜€! ๐Ÿš€๐Ÿ”ฅ Upgrโ€ฆ
  5. Oct 7, 2026๐Ÿ“Š Kandinsky 6.0 Video: AI-Powered Content Creation for Analysts The new Kandinsky 6.0 Vidโ€ฆ
  6. Oct 7, 2026Alternatively, depending on the Excel version and requirement, I could use functions suchโ€ฆ
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’