← 30 Days of SQL
Day 1 / 30Basics

SQL Basics — SELECT, FROM, WHERE

Every SQL interview starts here. These are the most common questions asked at every level — fresher to senior. Master these before anything else.

1
Easy

What is SQL and why is it used in data analytics?

SQL Answer
SQL (Structured Query Language) is used to query and manipulate data stored in relational databases.
💡

Data analysts use SQL daily to extract insights from databases — filtering sales data, aggregating customer records, joining multiple tables to answer business questions.

2
Easy

Write a query to select all columns from a table called "employees".

SQL Answer
SELECT * FROM employees;
💡

The * wildcard selects all columns. In production, always name specific columns instead of * for better performance and clarity.

3
Easy

How do you filter rows where salary is greater than 50000?

SQL Answer
SELECT * FROM employees
WHERE salary > 50000;
💡

WHERE filters rows before they are returned. Common operators: >, <, >=, <=, =, != (or <>).

4
Easy

Select employees from the "Sales" department only.

SQL Answer
SELECT * FROM employees
WHERE department = 'Sales';
💡

String values in WHERE must use single quotes. SQL is case-insensitive for keywords but case-sensitive for string values depending on the database.

5
Easy

How do you combine two conditions — salary > 40000 AND department = "HR"?

SQL Answer
SELECT * FROM employees
WHERE salary > 40000
  AND department = 'HR';
💡

AND requires both conditions to be true. OR requires at least one. Use parentheses when combining AND/OR to control precedence.

6
Medium

What is the difference between WHERE and HAVING?

SQL Answer
-- WHERE filters individual rows BEFORE grouping:
SELECT department, COUNT(*)
FROM employees
WHERE salary > 30000
GROUP BY department;

-- HAVING filters groups AFTER grouping:
SELECT department, COUNT(*)
FROM employees
GROUP BY department
HAVING COUNT(*) > 5;
💡

WHERE cannot reference aggregate functions (COUNT, SUM, etc.) because it runs before GROUP BY. HAVING runs after GROUP BY and can filter on aggregates.

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 →
NEXT →Day 2: ORDER BY, LIMIT and DISTINCT
Best Data Analytics Course in Noida Delhi NCR | EVIKA ACADEMY