Here are some essential SQL tips for beginners ππ
β Primary Key = Unique Key + Not Null constraint
β To perform case insensitive search use UPPER() function ex. UPPER(customer_name) LIKE βA%Aβ
β LIKE operator is for string data type
β COUNT(*), COUNT(1), COUNT(0) all are same
β All aggregate functions ignore the NULL values
β Aggregate functions MIN, MAX, SUM, AVG, COUNT are for int data type whereas STRING_AGG is for string data type
β For row level filtration use WHERE and aggregate level filtration use HAVING
β UNION ALL will include duplicates where as UNION excludes duplicates
β If the results will not have any duplicates, use UNION ALL instead of UNION
β We have to alias the subquery if we are using the columns in the outer select query
β Subqueries can be used as output with NOT IN condition.
β CTEs look better than subqueries. Performance wise both are same.
β When joining two tables , if one table has only one value then we can use 1=1 as a condition to join the tables. This will be considered as CROSS JOIN.
β Window functions work at ROW level.
β The difference between RANK() and DENSE_RANK() is that RANK() skips the rank if the values are the same.
β EXISTS works on true/false conditions. If the query returns at least one value, the condition is TRUE. All the records corresponding to the conditions are returned.
Like for more ππ
β Primary Key = Unique Key + Not Null constraint
β To perform case insensitive search use UPPER() function ex. UPPER(customer_name) LIKE βA%Aβ
β LIKE operator is for string data type
β COUNT(*), COUNT(1), COUNT(0) all are same
β All aggregate functions ignore the NULL values
β Aggregate functions MIN, MAX, SUM, AVG, COUNT are for int data type whereas STRING_AGG is for string data type
β For row level filtration use WHERE and aggregate level filtration use HAVING
β UNION ALL will include duplicates where as UNION excludes duplicates
β If the results will not have any duplicates, use UNION ALL instead of UNION
β We have to alias the subquery if we are using the columns in the outer select query
β Subqueries can be used as output with NOT IN condition.
β CTEs look better than subqueries. Performance wise both are same.
β When joining two tables , if one table has only one value then we can use 1=1 as a condition to join the tables. This will be considered as CROSS JOIN.
β Window functions work at ROW level.
β The difference between RANK() and DENSE_RANK() is that RANK() skips the rank if the values are the same.
β EXISTS works on true/false conditions. If the query returns at least one value, the condition is TRUE. All the records corresponding to the conditions are returned.
Like for more ππ
β€4
π SQL Fundamentals Part-4: JOINS
In real databases, data is stored in multiple tables, not one big table. JOINS allow you to combine data from different tables.
Example:
Customers Table
customer_id | name
1 | Rahul
2 | Priya
Orders Table
order_id | customer_id | amount
101 | 1 | 500
102 | 2 | 300
To see customer name + order amount, we must use JOIN.
Basic JOIN Syntax
SELECT columns
FROM table1
JOIN table2
ON table1.column = table2.column;
ON defines the relationship between tables.
1οΈβ£ INNER JOIN
Returns only matching records from both tables.
SELECT customers.name, orders.amount
FROM customers
INNER JOIN orders
ON customers.customer_id = orders.customer_id;
Result:
name | amount
Rahul | 500
Priya | 300
π If a customer has no order, they will not appear.
2οΈβ£ LEFT JOIN (Very Common β)
Returns: All rows from left table, Matching rows from right table, If no match β NULL
SELECT customers.name, orders.amount
FROM customers
LEFT JOIN orders
ON customers.customer_id = orders.customer_id;
Result:
name | amount
Rahul | 500
Priya | 300
Amit | NULL
π Amit has no order.
3οΈβ£ RIGHT JOIN
Opposite of LEFT JOIN. Returns: All rows from right table, Matching rows from left table
SELECT customers.name, orders.amount
FROM customers
RIGHT JOIN orders
ON customers.customer_id = orders.customer_id;
Used less frequently in analytics.
4οΈβ£ FULL JOIN
Returns: All records from both tables, If no match β NULL
SELECT customers.name, orders.amount
FROM customers
FULL JOIN orders
ON customers.customer_id = orders.customer_id;
5οΈβ£ SELF JOIN
A table joins with itself. Used when rows relate to other rows in the same table.
SELECT e.name AS employee, m.name AS manager
FROM employees e
LEFT JOIN employees m
ON e.manager_id = m.employee_id;
JOIN Visual Understanding
β’ INNER JOIN: Only matching rows
β’ LEFT JOIN: All left + matching right
β’ RIGHT JOIN: All right + matching left
β’ FULL JOIN: All rows from both
β’ SELF JOIN: Table joined with itself
Real Data Analyst Examples
-- Customer order report
SELECT c.name, o.amount
FROM customers c
JOIN orders o
ON c.customer_id = o.customer_id;
-- Products with category
SELECT p.product_name, c.category
FROM products p
JOIN categories c
ON p.category_id = c.category_id;
-- Sales by region
SELECT r.region_name, SUM(s.amount)
FROM sales s
JOIN regions r
ON s.region_id = r.region_id
GROUP BY r.region_name;
Used daily in Power BI dashboards, analytics queries, and reports.
Mini Practice Tasks
1. Show customer names with their order amount.
2. Show all customers even if they have no orders.
3. Show employees with their manager names.
4. Show products with their category name.
Common Interview Questions
β Difference between INNER JOIN and LEFT JOIN
β When to use SELF JOIN
β Why LEFT JOIN is used in analytics
β Difference between JOIN and UNION
β Join execution order
Double Tap β₯οΈ For More
In real databases, data is stored in multiple tables, not one big table. JOINS allow you to combine data from different tables.
Example:
Customers Table
customer_id | name
1 | Rahul
2 | Priya
Orders Table
order_id | customer_id | amount
101 | 1 | 500
102 | 2 | 300
To see customer name + order amount, we must use JOIN.
Basic JOIN Syntax
SELECT columns
FROM table1
JOIN table2
ON table1.column = table2.column;
ON defines the relationship between tables.
1οΈβ£ INNER JOIN
Returns only matching records from both tables.
SELECT customers.name, orders.amount
FROM customers
INNER JOIN orders
ON customers.customer_id = orders.customer_id;
Result:
name | amount
Rahul | 500
Priya | 300
π If a customer has no order, they will not appear.
2οΈβ£ LEFT JOIN (Very Common β)
Returns: All rows from left table, Matching rows from right table, If no match β NULL
SELECT customers.name, orders.amount
FROM customers
LEFT JOIN orders
ON customers.customer_id = orders.customer_id;
Result:
name | amount
Rahul | 500
Priya | 300
Amit | NULL
π Amit has no order.
3οΈβ£ RIGHT JOIN
Opposite of LEFT JOIN. Returns: All rows from right table, Matching rows from left table
SELECT customers.name, orders.amount
FROM customers
RIGHT JOIN orders
ON customers.customer_id = orders.customer_id;
Used less frequently in analytics.
4οΈβ£ FULL JOIN
Returns: All records from both tables, If no match β NULL
SELECT customers.name, orders.amount
FROM customers
FULL JOIN orders
ON customers.customer_id = orders.customer_id;
5οΈβ£ SELF JOIN
A table joins with itself. Used when rows relate to other rows in the same table.
SELECT e.name AS employee, m.name AS manager
FROM employees e
LEFT JOIN employees m
ON e.manager_id = m.employee_id;
JOIN Visual Understanding
β’ INNER JOIN: Only matching rows
β’ LEFT JOIN: All left + matching right
β’ RIGHT JOIN: All right + matching left
β’ FULL JOIN: All rows from both
β’ SELF JOIN: Table joined with itself
Real Data Analyst Examples
-- Customer order report
SELECT c.name, o.amount
FROM customers c
JOIN orders o
ON c.customer_id = o.customer_id;
-- Products with category
SELECT p.product_name, c.category
FROM products p
JOIN categories c
ON p.category_id = c.category_id;
-- Sales by region
SELECT r.region_name, SUM(s.amount)
FROM sales s
JOIN regions r
ON s.region_id = r.region_id
GROUP BY r.region_name;
Used daily in Power BI dashboards, analytics queries, and reports.
Mini Practice Tasks
1. Show customer names with their order amount.
2. Show all customers even if they have no orders.
3. Show employees with their manager names.
4. Show products with their category name.
Common Interview Questions
β Difference between INNER JOIN and LEFT JOIN
β When to use SELF JOIN
β Why LEFT JOIN is used in analytics
β Difference between JOIN and UNION
β Join execution order
Double Tap β₯οΈ For More
β€13
SQL Detailed Roadmap
|
| | |-- Fundamentals
| |-- Introduction to Databases
| | |-- What SQL does
| | |-- Relational model
| | |-- Tables, rows, columns
| |-- Keys and Constraints
| | |-- Primary keys
| | |-- Foreign keys
| | |-- Unique and check constraints
| |-- Normalization
| | |-- 1NF, 2NF, 3NF
| | |-- ER diagrams
| | |-- Core SQL
| |-- SQL Basics
| | |-- SELECT, WHERE, ORDER BY
| | |-- GROUP BY and HAVING
| | |-- JOINS: INNER, LEFT, RIGHT, FULL
| |-- Intermediate SQL
| | |-- Subqueries
| | |-- CTEs
| | |-- CASE statements
| | |-- Aggregations
| |-- Advanced SQL
| | |-- Window functions
| | |-- Analytical functions
| | |-- Ranking, moving averages, lag and lead
| | |-- UNION, INTERSECT, EXCEPT
| | |-- Data Management
| |-- Data Types
| | |-- Numeric, text, date, JSON
| |-- Indexes
| | |-- B tree and hash indexes
| | |-- When to create indexes
| |-- Transactions
| | |-- ACID properties
| |-- Views
| | |-- Standard views
| | |-- Materialized views
| | |-- Database Design
| |-- Schema Design
| | |-- Star schema
| | |-- Snowflake schema
| |-- Fact and Dimension Tables
| |-- Constraints for clean data
| | |-- Performance Tuning
| |-- Query Optimization
| | |-- Execution plans
| | |-- Index usage
| | |-- Reducing scans
| |-- Partitioning
| | |-- Horizontal partitioning
| | |-- Sharding basics
| | |-- SQL for Analytics
| |-- KPI calculations
| |-- Cohort analysis
| |-- Funnel analysis
| |-- Churn and retention tables
| |-- Time based aggregations
| |-- Window functions for metrics
| | |-- SQL for Data Engineering
| |-- ETL Workflows
| | |-- Staging tables
| | |-- Transformations
| | |-- Incremental loads
| |-- Data Warehousing
| | |-- Snowflake
| | |-- Redshift
| | |-- BigQuery
| |-- dbt Basics
| | |-- Models
| | |-- Tests
| | |-- Lineage
| | |-- Tools and Platforms
| |-- PostgreSQL
| |-- MySQL
| |-- SQL Server
| |-- Oracle
| |-- SQLite
| |-- Cloud SQL
| |-- BigQuery UI
| |-- Snowflake Worksheets
| | |-- Projects
| |-- Build a sales reporting system
| |-- Create a star schema from raw CSV files
| |-- Design a customer segmentation query
| |-- Build a churn dashboard dataset
| |-- Optimize slow queries in a sample DB
| |-- Create an analytics pipeline with dbt
| | |-- Soft Skills and Career Prep
| |-- SQL interview patterns
| |-- Joins practice
| |-- Window function drills
| |-- Query writing speed
| |-- Git and GitHub
| |-- Data storytelling
| | |-- Bonus Topics
| |-- NoSQL intro
| |-- Working with JSON fields
| |-- Spatial SQL
| |-- Time series tables
| |-- CDC concepts
| |-- Real time analytics
| | |-- Community and Growth
| |-- LeetCode SQL
| |-- Kaggle datasets with SQL
| |-- GitHub projects
| |-- LinkedIn posts
| |-- Open source contributions
Free Resources to learn SQL
β’ W3Schools SQL
https://www.w3schools.com/sql/
β’ SQL Programming
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
β’ SQL Notes
https://whatsapp.com/channel/0029Vb6hJmM9hXFCWNtQX944
β’ Mode Analytics SQL tutorials
https://mode.com/sql-tutorial/
β’ Data Analytics Resources
https://t.me/sqlspecialist
β’ HackerRank SQL practice
https://www.hackerrank.com/domains/sql
β’ LeetCode SQL problems
https://leetcode.com/problemset/database/
β’ Data Engineering Resources
https://whatsapp.com/channel/0029Vaovs0ZKbYMKXvKRYi3C
β’ Khan Academy SQL basics
https://www.khanacademy.org/computing/computer-programming/sql
β’ PostgreSQL official docs
https://www.postgresql.org/docs/
β’ MySQL official docs
https://dev.mysql.com/doc/
β’ NoSQL Resources
https://whatsapp.com/channel/0029VaxA2hTHgZWe5FpFjm3p
Double Tap β€οΈ For More
|
| | |-- Fundamentals
| |-- Introduction to Databases
| | |-- What SQL does
| | |-- Relational model
| | |-- Tables, rows, columns
| |-- Keys and Constraints
| | |-- Primary keys
| | |-- Foreign keys
| | |-- Unique and check constraints
| |-- Normalization
| | |-- 1NF, 2NF, 3NF
| | |-- ER diagrams
| | |-- Core SQL
| |-- SQL Basics
| | |-- SELECT, WHERE, ORDER BY
| | |-- GROUP BY and HAVING
| | |-- JOINS: INNER, LEFT, RIGHT, FULL
| |-- Intermediate SQL
| | |-- Subqueries
| | |-- CTEs
| | |-- CASE statements
| | |-- Aggregations
| |-- Advanced SQL
| | |-- Window functions
| | |-- Analytical functions
| | |-- Ranking, moving averages, lag and lead
| | |-- UNION, INTERSECT, EXCEPT
| | |-- Data Management
| |-- Data Types
| | |-- Numeric, text, date, JSON
| |-- Indexes
| | |-- B tree and hash indexes
| | |-- When to create indexes
| |-- Transactions
| | |-- ACID properties
| |-- Views
| | |-- Standard views
| | |-- Materialized views
| | |-- Database Design
| |-- Schema Design
| | |-- Star schema
| | |-- Snowflake schema
| |-- Fact and Dimension Tables
| |-- Constraints for clean data
| | |-- Performance Tuning
| |-- Query Optimization
| | |-- Execution plans
| | |-- Index usage
| | |-- Reducing scans
| |-- Partitioning
| | |-- Horizontal partitioning
| | |-- Sharding basics
| | |-- SQL for Analytics
| |-- KPI calculations
| |-- Cohort analysis
| |-- Funnel analysis
| |-- Churn and retention tables
| |-- Time based aggregations
| |-- Window functions for metrics
| | |-- SQL for Data Engineering
| |-- ETL Workflows
| | |-- Staging tables
| | |-- Transformations
| | |-- Incremental loads
| |-- Data Warehousing
| | |-- Snowflake
| | |-- Redshift
| | |-- BigQuery
| |-- dbt Basics
| | |-- Models
| | |-- Tests
| | |-- Lineage
| | |-- Tools and Platforms
| |-- PostgreSQL
| |-- MySQL
| |-- SQL Server
| |-- Oracle
| |-- SQLite
| |-- Cloud SQL
| |-- BigQuery UI
| |-- Snowflake Worksheets
| | |-- Projects
| |-- Build a sales reporting system
| |-- Create a star schema from raw CSV files
| |-- Design a customer segmentation query
| |-- Build a churn dashboard dataset
| |-- Optimize slow queries in a sample DB
| |-- Create an analytics pipeline with dbt
| | |-- Soft Skills and Career Prep
| |-- SQL interview patterns
| |-- Joins practice
| |-- Window function drills
| |-- Query writing speed
| |-- Git and GitHub
| |-- Data storytelling
| | |-- Bonus Topics
| |-- NoSQL intro
| |-- Working with JSON fields
| |-- Spatial SQL
| |-- Time series tables
| |-- CDC concepts
| |-- Real time analytics
| | |-- Community and Growth
| |-- LeetCode SQL
| |-- Kaggle datasets with SQL
| |-- GitHub projects
| |-- LinkedIn posts
| |-- Open source contributions
Free Resources to learn SQL
β’ W3Schools SQL
https://www.w3schools.com/sql/
β’ SQL Programming
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
β’ SQL Notes
https://whatsapp.com/channel/0029Vb6hJmM9hXFCWNtQX944
β’ Mode Analytics SQL tutorials
https://mode.com/sql-tutorial/
β’ Data Analytics Resources
https://t.me/sqlspecialist
β’ HackerRank SQL practice
https://www.hackerrank.com/domains/sql
β’ LeetCode SQL problems
https://leetcode.com/problemset/database/
β’ Data Engineering Resources
https://whatsapp.com/channel/0029Vaovs0ZKbYMKXvKRYi3C
β’ Khan Academy SQL basics
https://www.khanacademy.org/computing/computer-programming/sql
β’ PostgreSQL official docs
https://www.postgresql.org/docs/
β’ MySQL official docs
https://dev.mysql.com/doc/
β’ NoSQL Resources
https://whatsapp.com/channel/0029VaxA2hTHgZWe5FpFjm3p
Double Tap β€οΈ For More
β€9
β‘ Subqueries CTEs
After mastering JOINS, the next important concept is Subqueries and CTEs. These are used when queries become complex and you need intermediate results.
π Very common in data analyst interviews and real analytics queries.
πΉ 1οΈβ£ What is a Subquery?
A subquery is a query inside another SQL query. It is executed first, and its result is used by the main query.
π― Basic Syntax
π§ Example 1 β Find Employees with Highest Salary
Explanation:
1οΈβ£ Inner query finds maximum salary
2οΈβ£ Outer query finds employee with that salary
πΉ 2οΈβ£ Subquery in WHERE Clause
Most common use.
Example β Employees earning more than average salary
Used heavily in analytics queries.
πΉ 3οΈβ£ Subquery in FROM Clause
Also called Derived Table.
Used when intermediate results are required.
πΉ 4οΈβ£ EXISTS / NOT EXISTS
Used to check if a record exists in another table.
Example β Customers who placed orders
π Returns customers with orders.
Example β Customers with no orders
β 5οΈβ£ Common Table Expressions (CTEs)
CTEs improve query readability and structure. Defined using WITH clause.
Basic Syntax
π§ Example β Average Salary by Department
πΉ 6οΈβ£ Multiple CTEs
You can chain multiple CTEs.
Used often in complex analytics queries.
π§ Real Analyst Examples
Customers with above average purchases
Complex analytics often uses subqueries or CTEs.
π Mini Practice Tasks
π― Task 1 β Find employees earning more than average salary
β Solution
π‘ Explanation: Subquery calculates average salary, Outer query filters employees above average.
π― Task 2 β Find customers who placed orders
β Solution (Using EXISTS β)
π‘ Explanation: Checks if an order exists for the customer.
π― Task 3 β Find departments with salary greater than company average
β Solution
π‘ Explanation: Subquery finds company average salary, HAVING filters departments above that average.
π― Task 4 β Use a CTE to calculate total sales per customer
β Solution
π‘ Explanation: CTE calculates total sales for each customer, Main query retrieves the result.
Double Tap β₯οΈ For More
After mastering JOINS, the next important concept is Subqueries and CTEs. These are used when queries become complex and you need intermediate results.
π Very common in data analyst interviews and real analytics queries.
πΉ 1οΈβ£ What is a Subquery?
A subquery is a query inside another SQL query. It is executed first, and its result is used by the main query.
π― Basic Syntax
SELECT column
FROM table
WHERE column = (SELECT column FROM table);
π§ Example 1 β Find Employees with Highest Salary
SELECT name, salary
FROM employees
WHERE salary = (SELECT MAX(salary) FROM employees);
Explanation:
1οΈβ£ Inner query finds maximum salary
2οΈβ£ Outer query finds employee with that salary
πΉ 2οΈβ£ Subquery in WHERE Clause
Most common use.
Example β Employees earning more than average salary
SELECT name, salary
FROM employees
WHERE salary > (SELECT AVG(salary) FROM employees);
Used heavily in analytics queries.
πΉ 3οΈβ£ Subquery in FROM Clause
Also called Derived Table.
SELECT department, AVG(avg_salary)
FROM (
SELECT department, AVG(salary) AS avg_salary
FROM employees
GROUP BY department
) AS dept_salary
GROUP BY department;
Used when intermediate results are required.
πΉ 4οΈβ£ EXISTS / NOT EXISTS
Used to check if a record exists in another table.
Example β Customers who placed orders
SELECT name
FROM customers c
WHERE EXISTS (
SELECT 1
FROM orders o
WHERE c.customer_id = o.customer_id
);
π Returns customers with orders.
Example β Customers with no orders
SELECT name
FROM customers c
WHERE NOT EXISTS (
SELECT 1
FROM orders o
WHERE c.customer_id = o.customer_id
);
β 5οΈβ£ Common Table Expressions (CTEs)
CTEs improve query readability and structure. Defined using WITH clause.
Basic Syntax
WITH cte_name AS (
SELECT column
FROM table
)
SELECT *
FROM cte_name;
π§ Example β Average Salary by Department
WITH dept_avg AS (
SELECT department, AVG(salary) AS avg_salary
FROM employees
GROUP BY department
)
SELECT *
FROM dept_avg;
πΉ 6οΈβ£ Multiple CTEs
You can chain multiple CTEs.
WITH total_sales AS (
SELECT customer_id, SUM(amount) AS total
FROM orders
GROUP BY customer_id
),
top_customers AS (
SELECT *
FROM total_sales
WHERE total > 1000
)
SELECT *
FROM top_customers;
Used often in complex analytics queries.
π§ Real Analyst Examples
Customers with above average purchases
SELECT customer_id
FROM orders
GROUP BY customer_id
HAVING SUM(amount) > (
SELECT AVG(total)
FROM (
SELECT SUM(amount) AS total
FROM orders
GROUP BY customer_id
) AS totals
);
Complex analytics often uses subqueries or CTEs.
π Mini Practice Tasks
π― Task 1 β Find employees earning more than average salary
β Solution
SELECT name, salary
FROM employees
WHERE salary > (SELECT AVG(salary) FROM employees);
π‘ Explanation: Subquery calculates average salary, Outer query filters employees above average.
π― Task 2 β Find customers who placed orders
β Solution (Using EXISTS β)
SELECT name
FROM customers c
WHERE EXISTS (
SELECT 1
FROM orders o
WHERE c.customer_id = o.customer_id
);
π‘ Explanation: Checks if an order exists for the customer.
π― Task 3 β Find departments with salary greater than company average
β Solution
SELECT department, AVG(salary)
FROM employees
GROUP BY department
HAVING AVG(salary) > (SELECT AVG(salary) FROM employees);
π‘ Explanation: Subquery finds company average salary, HAVING filters departments above that average.
π― Task 4 β Use a CTE to calculate total sales per customer
β Solution
WITH customer_sales AS (
SELECT customer_id, SUM(amount) AS total_sales
FROM orders
GROUP BY customer_id
)
SELECT * FROM customer_sales;
π‘ Explanation: CTE calculates total sales for each customer, Main query retrieves the result.
Double Tap β₯οΈ For More
β€9
What will this query return?
SELECT name FROM employees WHERE salary > (SELECT salary FROM employees);
SELECT name FROM employees WHERE salary > (SELECT salary FROM employees);
Anonymous Quiz
41%
A) Employees with highest salary
44%
B) Error: Subquery returns multiple rows
12%
C) All employees
3%
D) Only first employee
What will this query output?
SELECT * FROM employees WHERE department_id IN ( SELECT department_id FROM departments );
SELECT * FROM employees WHERE department_id IN ( SELECT department_id FROM departments );
Anonymous Quiz
75%
A) Employees with departments listed in the departments table
14%
B) All employees
6%
C) No employees
5%
D) Only department names
What is the output of this query?
WITH numbers AS ( SELECT 10 AS value UNION SELECT 20 ) SELECT SUM(value) FROM numbers;
WITH numbers AS ( SELECT 10 AS value UNION SELECT 20 ) SELECT SUM(value) FROM numbers;
Anonymous Quiz
10%
A) 10
18%
B) 20
49%
C) 30
24%
D) Error
What will this query return?
SELECT name FROM customers WHERE NOT EXISTS ( SELECT * FROM orders WHERE customers.customer_id = orders.customer_id );
SELECT name FROM customers WHERE NOT EXISTS ( SELECT * FROM orders WHERE customers.customer_id = orders.customer_id );
Anonymous Quiz
25%
A) Customers who placed orders
66%
B) Customers without orders
6%
C) All customers
3%
D) Only order details
β€1
π§ SQL Interview Question (ModerateβTricky & Duplicate Transaction Detection)
π
transactions(transaction_id, user_id, transaction_date, amount)
β Ques :
π Find users who made multiple transactions with the same amount consecutively.
π§© How Interviewers Expect You to Think
β’ Sort transactions chronologically for each user
β’ Compare the current transaction amount with the previous one
β’ Use a window function to detect consecutive duplicates
π‘ SQL Solution
SELECT
user_id,
transaction_date,
amount
FROM (
SELECT
user_id,
transaction_date,
amount,
LAG(amount) OVER (
PARTITION BY user_id
ORDER BY transaction_date
) AS prev_amount
FROM transactions
) t
WHERE amount = prev_amount;
π₯ Why This Question Is Powerful
β’ Tests understanding of LAG() for row comparison
β’ Evaluates ability to identify patterns in sequential data
β’ Reflects real-world use cases like detecting suspicious or duplicate transactions
β€οΈ React if you want more tricky real interview-level SQL questions π
π
transactions(transaction_id, user_id, transaction_date, amount)
β Ques :
π Find users who made multiple transactions with the same amount consecutively.
π§© How Interviewers Expect You to Think
β’ Sort transactions chronologically for each user
β’ Compare the current transaction amount with the previous one
β’ Use a window function to detect consecutive duplicates
π‘ SQL Solution
SELECT
user_id,
transaction_date,
amount
FROM (
SELECT
user_id,
transaction_date,
amount,
LAG(amount) OVER (
PARTITION BY user_id
ORDER BY transaction_date
) AS prev_amount
FROM transactions
) t
WHERE amount = prev_amount;
π₯ Why This Question Is Powerful
β’ Tests understanding of LAG() for row comparison
β’ Evaluates ability to identify patterns in sequential data
β’ Reflects real-world use cases like detecting suspicious or duplicate transactions
β€οΈ React if you want more tricky real interview-level SQL questions π
β€12
π Window Functions β
Window functions are one of the most powerful SQL features used in data analytics, reporting, and advanced SQL interviews.
π They allow you to perform calculations across rows without collapsing them like GROUP BY.
In simple words:
GROUP BY β reduces rows
Window Functions β keep rows but add calculated values
π§ Basic Syntax of Window Functions
- OVER() β defines the window
- PARTITION BY β splits data into groups
- ORDER BY β defines calculation order
πΉ 1οΈβ£ ROW_NUMBER()
Assigns a unique sequential number to rows.
name | salary | rank
Rahul | 90000 | 1
Priya | 85000 | 2
Amit | 85000 | 3
π Even if salaries are same, numbers stay unique.
πΉ 2οΈβ£ RANK()
Assigns rank but skips numbers when ties occur.
name | salary | rank
Rahul | 90000 | 1
Priya | 85000 | 2
Amit | 85000 | 2
Neha | 80000 | 4
Notice rank 3 is skipped.
πΉ 3οΈβ£ DENSE_RANK()
Similar to RANK but does not skip numbers.
name | salary | rank
Rahul | 90000 | 1
Priya | 85000 | 2
Amit | 85000 | 2
Neha | 80000 | 3
πΉ 4οΈβ£ PARTITION BY
Used to divide rows into groups before calculation.
Example: Rank employees within each department
πΉ 5οΈβ£ LAG()
Used to access previous row values.
Example: Compare sales with previous day.
Used to access next row values.
Top 3 highest salaries
β Difference between ROW_NUMBER, RANK, DENSE_RANK
β Find Nth highest salary
β Running totals using window functions
β Compare current row with previous row
β Rank employees by department
π Mini Practice Tasks
Task 1: Assign row numbers to employees by salary.
Task 2: Rank employees by salary.
Task 3: Find top 3 highest salaries using window functions.
Task 4: Calculate running total of sales.
πΌ What You Must Master
β ROW_NUMBER()
β RANK()
β DENSE_RANK()
β PARTITION BY
β LAG() / LEAD()
β Running totals
These functions are used heavily in real analytics queries and SQL interviews.
Double Tap β₯οΈ For More
Window functions are one of the most powerful SQL features used in data analytics, reporting, and advanced SQL interviews.
π They allow you to perform calculations across rows without collapsing them like GROUP BY.
In simple words:
GROUP BY β reduces rows
Window Functions β keep rows but add calculated values
π§ Basic Syntax of Window Functions
SELECT column, window_function()Components:
OVER (
PARTITION BY column
ORDER BY column
)
FROM table;
- OVER() β defines the window
- PARTITION BY β splits data into groups
- ORDER BY β defines calculation order
πΉ 1οΈβ£ ROW_NUMBER()
Assigns a unique sequential number to rows.
SELECT name, salary, ROW_NUMBER() OVER(ORDER BY salary DESC) AS rankResult:
FROM employees;
name | salary | rank
Rahul | 90000 | 1
Priya | 85000 | 2
Amit | 85000 | 3
π Even if salaries are same, numbers stay unique.
πΉ 2οΈβ£ RANK()
Assigns rank but skips numbers when ties occur.
SELECT name, salary, RANK() OVER(ORDER BY salary DESC) AS rankResult:
FROM employees;
name | salary | rank
Rahul | 90000 | 1
Priya | 85000 | 2
Amit | 85000 | 2
Neha | 80000 | 4
Notice rank 3 is skipped.
πΉ 3οΈβ£ DENSE_RANK()
Similar to RANK but does not skip numbers.
SELECT name, salary, DENSE_RANK() OVER(ORDER BY salary DESC) AS rankResult:
FROM employees;
name | salary | rank
Rahul | 90000 | 1
Priya | 85000 | 2
Amit | 85000 | 2
Neha | 80000 | 3
πΉ 4οΈβ£ PARTITION BY
Used to divide rows into groups before calculation.
Example: Rank employees within each department
SELECT name, department, salary,π Each department gets its own ranking.
RANK() OVER(
PARTITION BY department
ORDER BY salary DESC
) AS dept_rank
FROM employees;
πΉ 5οΈβ£ LAG()
Used to access previous row values.
Example: Compare sales with previous day.
SELECT date, sales, LAG(sales) OVER(ORDER BY date) AS previous_salesπΉ 6οΈβ£ LEAD()
FROM sales;
Used to access next row values.
SELECT date, sales, LEAD(sales) OVER(ORDER BY date) AS next_salesβ Real Data Analyst Examples
FROM sales;
Top 3 highest salaries
SELECT **Running total of sales
FROM (
SELECT name, salary, ROW_NUMBER() OVER(ORDER BY salary DESC) AS rn
FROM employees
) t
WHERE rn <= 3;
SELECT date, sales, SUM(sales) OVER(ORDER BY date) AS running_totalRank products by category
FROM sales;
SELECT product_name, category, price,π― Common Interview Questions
RANK() OVER(PARTITION BY category ORDER BY price DESC) AS rank
FROM products;
β Difference between ROW_NUMBER, RANK, DENSE_RANK
β Find Nth highest salary
β Running totals using window functions
β Compare current row with previous row
β Rank employees by department
π Mini Practice Tasks
Task 1: Assign row numbers to employees by salary.
Task 2: Rank employees by salary.
Task 3: Find top 3 highest salaries using window functions.
Task 4: Calculate running total of sales.
πΌ What You Must Master
β ROW_NUMBER()
β RANK()
β DENSE_RANK()
β PARTITION BY
β LAG() / LEAD()
β Running totals
These functions are used heavily in real analytics queries and SQL interviews.
Double Tap β₯οΈ For More
β€10
β
Useful Platform to Practice SQL Programming π§ π₯οΈ
Learning SQL is just the first step β practice is what builds real skill. Here are the best platforms for hands-on SQL:
1οΈβ£ LeetCode β For Interview-Oriented SQL Practice
β’ Focus: Real interview-style problems
β’ Levels: Easy to Hard
β’ Schema + Sample Data Provided
β’ Great for: Data Analyst, Data Engineer, FAANG roles
β Tip: Start with Easy β filter by βDatabaseβ tag
β Popular Section: Database β Top 50 SQL Questions
Example Problem: βFind duplicate emails in a user tableβ β Practice filtering, GROUP BY, HAVING
2οΈβ£ HackerRank β Structured & Beginner-Friendly
β’ Focus: Step-by-step SQL track
β’ Has certification tests (SQL Basic, Intermediate)
β’ Problem sets by topic: SELECT, JOINs, Aggregations, etc.
β Tip: Follow the full SQL track
β Bonus: Company-specific challenges
Try: βRevising Aggregations β The Count Functionβ β Build confidence with small wins
3οΈβ£ Mode Analytics β Real-World SQL in Business Context
β’ Focus: Business intelligence + SQL
β’ Uses real-world datasets (e.g., e-commerce, finance)
β’ Has an in-browser SQL editor with live data
β Best for: Practicing dashboard-level queries
β Tip: Try the SQL case studies & tutorials
4οΈβ£ StrataScratch β Interview Questions from Real Companies
β’ 500+ problems from companies like Uber, Netflix, Google
β’ Split by company, difficulty, and topic
β Best for: Intermediate to advanced level
β Tip: Try βHardβ questions after doing 30β50 easy/medium
5οΈβ£ DataLemur β Short, Practical SQL Problems
β’ Crisp and to the point
β’ Good UI, fast learning
β’ Real interview-style logic
β Use when: You want fast, smart SQL drills
π How to Practice Effectively:
β’ Spend 20β30 mins/day
β’ Focus on JOINs, GROUP BY, HAVING, Subqueries
β’ Analyze problem β write β debug β re-write
β’ After solving, explain your logic out loud
π§ͺ Practice Task:
Try solving 5 SQL questions from LeetCode or HackerRank this week. Start with SELECT, WHERE, and GROUP BY.
π¬ Tap β€οΈ for more!
Learning SQL is just the first step β practice is what builds real skill. Here are the best platforms for hands-on SQL:
1οΈβ£ LeetCode β For Interview-Oriented SQL Practice
β’ Focus: Real interview-style problems
β’ Levels: Easy to Hard
β’ Schema + Sample Data Provided
β’ Great for: Data Analyst, Data Engineer, FAANG roles
β Tip: Start with Easy β filter by βDatabaseβ tag
β Popular Section: Database β Top 50 SQL Questions
Example Problem: βFind duplicate emails in a user tableβ β Practice filtering, GROUP BY, HAVING
2οΈβ£ HackerRank β Structured & Beginner-Friendly
β’ Focus: Step-by-step SQL track
β’ Has certification tests (SQL Basic, Intermediate)
β’ Problem sets by topic: SELECT, JOINs, Aggregations, etc.
β Tip: Follow the full SQL track
β Bonus: Company-specific challenges
Try: βRevising Aggregations β The Count Functionβ β Build confidence with small wins
3οΈβ£ Mode Analytics β Real-World SQL in Business Context
β’ Focus: Business intelligence + SQL
β’ Uses real-world datasets (e.g., e-commerce, finance)
β’ Has an in-browser SQL editor with live data
β Best for: Practicing dashboard-level queries
β Tip: Try the SQL case studies & tutorials
4οΈβ£ StrataScratch β Interview Questions from Real Companies
β’ 500+ problems from companies like Uber, Netflix, Google
β’ Split by company, difficulty, and topic
β Best for: Intermediate to advanced level
β Tip: Try βHardβ questions after doing 30β50 easy/medium
5οΈβ£ DataLemur β Short, Practical SQL Problems
β’ Crisp and to the point
β’ Good UI, fast learning
β’ Real interview-style logic
β Use when: You want fast, smart SQL drills
π How to Practice Effectively:
β’ Spend 20β30 mins/day
β’ Focus on JOINs, GROUP BY, HAVING, Subqueries
β’ Analyze problem β write β debug β re-write
β’ After solving, explain your logic out loud
π§ͺ Practice Task:
Try solving 5 SQL questions from LeetCode or HackerRank this week. Start with SELECT, WHERE, and GROUP BY.
π¬ Tap β€οΈ for more!
β€15
βοΈ SQL Developer Roadmap
π SQL Basics (CREATE, DROP, USE Database)
βπ Data Types & DDL (Tables, Constraints - PK/FK)
βπ DML (INSERT, UPDATE, DELETE)
βπ SELECT Queries (DISTINCT, LIMIT/TOP)
βπ WHERE Clause (Operators, LIKE, IN, BETWEEN)
βπ ORDER BY & Sorting (ASC/DESC)
βπ Aggregate Functions (COUNT, SUM, AVG, MIN/MAX)
βπ GROUP BY & HAVING
βπ JOINs (INNER, LEFT, RIGHT, FULL)
βπ Subqueries
βπ String Functions (CONCAT, SUBSTRING, UPPER/LOWER)
βπ Date Functions (NOW, DATEADD, DATEDIFF)
βπ Window Functions (ROW_NUMBER, RANK, PARTITION BY)
βπ CTEs (Common Table Expressions)
βπ Indexes & Performance
βπ Transactions (BEGIN, COMMIT, ROLLBACK)
βπ Views & Stored Procedures
βπ Practice (LeetCode SQL, HackerRank)
ββ Apply for Data Analyst / Backend Roles
π¬ Tap β€οΈ for more!
π SQL Basics (CREATE, DROP, USE Database)
βπ Data Types & DDL (Tables, Constraints - PK/FK)
βπ DML (INSERT, UPDATE, DELETE)
βπ SELECT Queries (DISTINCT, LIMIT/TOP)
βπ WHERE Clause (Operators, LIKE, IN, BETWEEN)
βπ ORDER BY & Sorting (ASC/DESC)
βπ Aggregate Functions (COUNT, SUM, AVG, MIN/MAX)
βπ GROUP BY & HAVING
βπ JOINs (INNER, LEFT, RIGHT, FULL)
βπ Subqueries
βπ String Functions (CONCAT, SUBSTRING, UPPER/LOWER)
βπ Date Functions (NOW, DATEADD, DATEDIFF)
βπ Window Functions (ROW_NUMBER, RANK, PARTITION BY)
βπ CTEs (Common Table Expressions)
βπ Indexes & Performance
βπ Transactions (BEGIN, COMMIT, ROLLBACK)
βπ Views & Stored Procedures
βπ Practice (LeetCode SQL, HackerRank)
ββ Apply for Data Analyst / Backend Roles
π¬ Tap β€οΈ for more!
β€16
π₯ Top SQL Interview Questions with Answers
π― 1οΈβ£ Find 2nd Highest Salary
π Table: employees
id | name | salary
1 | Rahul | 50000
2 | Priya | 70000
3 | Amit | 60000
4 | Neha | 70000
β Problem Statement: Find the second highest distinct salary from the employees table.
β Solution
SELECT MAX(salary) FROM employees WHERE salary < ( SELECT MAX(salary) FROM employees );
π― 2οΈβ£ Find Nth Highest Salary
π Table: employees
id | name | salary
1 | A | 100
2 | B | 200
3 | C | 300
4 | D | 200
β Problem Statement: Write a query to find the 3rd highest salary.
β Solution
SELECT salary FROM ( SELECT salary, DENSE_RANK() OVER(ORDER BY salary DESC) r FROM employees ) t WHERE r = 3;
π― 3οΈβ£ Find Duplicate Records
π Table: employees
id | name
1 | Rahul
2 | Amit
3 | Rahul
4 | Neha
β Problem Statement: Find all duplicate names in the employees table.
β Solution
SELECT name, COUNT(*) FROM employees GROUP BY name HAVING COUNT(*) > 1;
π― 4οΈβ£ Customers with No Orders
π Table: customers
customer_id | name
1 | Rahul
2 | Priya
3 | Amit
π Table: orders
order_id | customer_id
101 | 1
102 | 2
β Problem Statement: Find customers who have not placed any orders.
β Solution
SELECT c.name FROM customers c LEFT JOIN orders o ON c.customer_id = o.customer_id WHERE o.customer_id IS NULL;
π― 5οΈβ£ Top 3 Salaries per Department
π Table: employees
name | department | salary
A | IT | 100
B | IT | 200
C | IT | 150
D | HR | 120
E | HR | 180
β Problem Statement: Find the top 3 highest salaries in each department.
β Solution
SELECT * FROM ( SELECT name, department, salary, ROW_NUMBER() OVER( PARTITION BY department ORDER BY salary DESC ) r FROM employees ) t WHERE r <= 3;
π― 6οΈβ£ Running Total of Sales
π Table: sales
date | sales
2024-01-01 | 100
2024-01-02 | 200
2024-01-03 | 300
β Problem Statement: Calculate the running total of sales by date.
β Solution
SELECT date, sales, SUM(sales) OVER(ORDER BY date) AS running_total FROM sales;
π― 7οΈβ£ Employees Above Average Salary
π Table: employees
name | salary
A | 100
B | 200
C | 300
β Problem Statement: Find employees earning more than the average salary.
β Solution
SELECT name, salary FROM employees WHERE salary > ( SELECT AVG(salary) FROM employees );
π― 8οΈβ£ Department with Highest Total Salary
π Table: employees
name | department | salary
A | IT | 100
B | IT | 200
C | HR | 500
β Problem Statement: Find the department with the highest total salary.
β Solution
SELECT department, SUM(salary) AS total_salary FROM employees GROUP BY department ORDER BY total_salary DESC LIMIT 1;
π― 9οΈβ£ Customers Who Placed Orders
π Tables: Same as Q4
β Problem Statement: Find customers who have placed at least one order.
β Solution
SELECT name FROM customers c WHERE EXISTS ( SELECT 1 FROM orders o WHERE c.customer_id = o.customer_id );
π― π Remove Duplicate Records
π Table: employees
id | name
1 | Rahul
2 | Rahul
3 | Amit
β Problem Statement: Delete duplicate records but keep one unique record.
β Solution
DELETE FROM employees WHERE id NOT IN ( SELECT MIN(id) FROM employees GROUP BY name );
π Pro Tip:
π In interviews:
First explain logic
Then write query
Then optimize
Double Tap β₯οΈ For More
π― 1οΈβ£ Find 2nd Highest Salary
π Table: employees
id | name | salary
1 | Rahul | 50000
2 | Priya | 70000
3 | Amit | 60000
4 | Neha | 70000
β Problem Statement: Find the second highest distinct salary from the employees table.
β Solution
SELECT MAX(salary) FROM employees WHERE salary < ( SELECT MAX(salary) FROM employees );
π― 2οΈβ£ Find Nth Highest Salary
π Table: employees
id | name | salary
1 | A | 100
2 | B | 200
3 | C | 300
4 | D | 200
β Problem Statement: Write a query to find the 3rd highest salary.
β Solution
SELECT salary FROM ( SELECT salary, DENSE_RANK() OVER(ORDER BY salary DESC) r FROM employees ) t WHERE r = 3;
π― 3οΈβ£ Find Duplicate Records
π Table: employees
id | name
1 | Rahul
2 | Amit
3 | Rahul
4 | Neha
β Problem Statement: Find all duplicate names in the employees table.
β Solution
SELECT name, COUNT(*) FROM employees GROUP BY name HAVING COUNT(*) > 1;
π― 4οΈβ£ Customers with No Orders
π Table: customers
customer_id | name
1 | Rahul
2 | Priya
3 | Amit
π Table: orders
order_id | customer_id
101 | 1
102 | 2
β Problem Statement: Find customers who have not placed any orders.
β Solution
SELECT c.name FROM customers c LEFT JOIN orders o ON c.customer_id = o.customer_id WHERE o.customer_id IS NULL;
π― 5οΈβ£ Top 3 Salaries per Department
π Table: employees
name | department | salary
A | IT | 100
B | IT | 200
C | IT | 150
D | HR | 120
E | HR | 180
β Problem Statement: Find the top 3 highest salaries in each department.
β Solution
SELECT * FROM ( SELECT name, department, salary, ROW_NUMBER() OVER( PARTITION BY department ORDER BY salary DESC ) r FROM employees ) t WHERE r <= 3;
π― 6οΈβ£ Running Total of Sales
π Table: sales
date | sales
2024-01-01 | 100
2024-01-02 | 200
2024-01-03 | 300
β Problem Statement: Calculate the running total of sales by date.
β Solution
SELECT date, sales, SUM(sales) OVER(ORDER BY date) AS running_total FROM sales;
π― 7οΈβ£ Employees Above Average Salary
π Table: employees
name | salary
A | 100
B | 200
C | 300
β Problem Statement: Find employees earning more than the average salary.
β Solution
SELECT name, salary FROM employees WHERE salary > ( SELECT AVG(salary) FROM employees );
π― 8οΈβ£ Department with Highest Total Salary
π Table: employees
name | department | salary
A | IT | 100
B | IT | 200
C | HR | 500
β Problem Statement: Find the department with the highest total salary.
β Solution
SELECT department, SUM(salary) AS total_salary FROM employees GROUP BY department ORDER BY total_salary DESC LIMIT 1;
π― 9οΈβ£ Customers Who Placed Orders
π Tables: Same as Q4
β Problem Statement: Find customers who have placed at least one order.
β Solution
SELECT name FROM customers c WHERE EXISTS ( SELECT 1 FROM orders o WHERE c.customer_id = o.customer_id );
π― π Remove Duplicate Records
π Table: employees
id | name
1 | Rahul
2 | Rahul
3 | Amit
β Problem Statement: Delete duplicate records but keep one unique record.
β Solution
DELETE FROM employees WHERE id NOT IN ( SELECT MIN(id) FROM employees GROUP BY name );
π Pro Tip:
π In interviews:
First explain logic
Then write query
Then optimize
Double Tap β₯οΈ For More
β€15
π Complete SQL Syllabus Roadmap (Beginner to Expert) ποΈ
π° Beginner Level:
1. Intro to Databases: What are databases, Relational vs. Non-Relational
2. SQL Basics: SELECT, FROM, WHERE
3. Data Types: INT, VARCHAR, DATE, BOOLEAN, etc.
4. Operators: Comparison, Logical (AND, OR, NOT)
5. Sorting & Filtering: ORDER BY, LIMIT, DISTINCT
6. Aggregate Functions: COUNT, SUM, AVG, MIN, MAX
7. GROUP BY and HAVING: Grouping Data and Filtering Groups
8. Basic Projects: Creating and querying a simple database (e.g., a student database)
βοΈ Intermediate Level:
1. Joins: INNER, LEFT, RIGHT, FULL OUTER JOIN
2. Subqueries: Using queries within queries
3. Indexes: Improving Query Performance
4. Data Modification: INSERT, UPDATE, DELETE
5. Transactions: ACID Properties, COMMIT, ROLLBACK
6. Constraints: PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT NULL, CHECK, DEFAULT
7. Views: Creating Virtual Tables
8. Stored Procedures & Functions: Reusable SQL Code
9. Date and Time Functions: Working with Date and Time Data
10. Intermediate Projects: Designing and querying a more complex database (e.g., an e-commerce database)
π Expert Level:
1. Window Functions: RANK, ROW_NUMBER, LAG, LEAD
2. Common Table Expressions (CTEs): Recursive and Non-Recursive
3. Performance Tuning: Query Optimization Techniques
4. Database Design & Normalization: Understanding Database Schemas (Star, Snowflake)
5. Advanced Indexing: Clustered, Non-Clustered, Filtered Indexes
6. Database Administration: Backup and Recovery, Security, User Management
7. Working with Large Datasets: Partitioning, Data Warehousing Concepts
8. NoSQL Databases: Introduction to MongoDB, Cassandra, etc. (optional)
9. SQL Injection Prevention: Secure Coding Practices
10. Expert Projects: Designing, optimizing, and managing a large-scale database (e.g., a social media database)
π‘ Bonus: Learn about Database Security, Cloud Databases (AWS RDS, Azure SQL Database, Google Cloud SQL), and Data Modeling Tools.
π Tap β€οΈ for more
π° Beginner Level:
1. Intro to Databases: What are databases, Relational vs. Non-Relational
2. SQL Basics: SELECT, FROM, WHERE
3. Data Types: INT, VARCHAR, DATE, BOOLEAN, etc.
4. Operators: Comparison, Logical (AND, OR, NOT)
5. Sorting & Filtering: ORDER BY, LIMIT, DISTINCT
6. Aggregate Functions: COUNT, SUM, AVG, MIN, MAX
7. GROUP BY and HAVING: Grouping Data and Filtering Groups
8. Basic Projects: Creating and querying a simple database (e.g., a student database)
βοΈ Intermediate Level:
1. Joins: INNER, LEFT, RIGHT, FULL OUTER JOIN
2. Subqueries: Using queries within queries
3. Indexes: Improving Query Performance
4. Data Modification: INSERT, UPDATE, DELETE
5. Transactions: ACID Properties, COMMIT, ROLLBACK
6. Constraints: PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT NULL, CHECK, DEFAULT
7. Views: Creating Virtual Tables
8. Stored Procedures & Functions: Reusable SQL Code
9. Date and Time Functions: Working with Date and Time Data
10. Intermediate Projects: Designing and querying a more complex database (e.g., an e-commerce database)
π Expert Level:
1. Window Functions: RANK, ROW_NUMBER, LAG, LEAD
2. Common Table Expressions (CTEs): Recursive and Non-Recursive
3. Performance Tuning: Query Optimization Techniques
4. Database Design & Normalization: Understanding Database Schemas (Star, Snowflake)
5. Advanced Indexing: Clustered, Non-Clustered, Filtered Indexes
6. Database Administration: Backup and Recovery, Security, User Management
7. Working with Large Datasets: Partitioning, Data Warehousing Concepts
8. NoSQL Databases: Introduction to MongoDB, Cassandra, etc. (optional)
9. SQL Injection Prevention: Secure Coding Practices
10. Expert Projects: Designing, optimizing, and managing a large-scale database (e.g., a social media database)
π‘ Bonus: Learn about Database Security, Cloud Databases (AWS RDS, Azure SQL Database, Google Cloud SQL), and Data Modeling Tools.
π Tap β€οΈ for more
β€8π1
SQL Cheat Sheet for Data Analysts ποΈπ
1. SELECT
What it is: Used to choose columns from a table
What it does: Returns specific columns of data
Query: Fetch name and salary
2. FROM
What it is: Specifies the table
What it does: Tells SQL where to get data from
Query: Fetch all data from employees
3. WHERE
What it is: Filters rows based on condition
What it does: Returns only matching rows
Query: Employees with salary > 30000
4. ORDER BY
What it is: Sorts the data
What it does: Arranges rows in order
Query: Sort by salary (highest first)
5. COUNT()
What it is: Counts rows
What it does: Returns total records
Query: Count employees
6. AVG()
What it is: Calculates average
What it does: Returns mean value
Query: Average salary
7. GROUP BY
What it is: Groups rows by column
What it does: Applies aggregation per group
Query: Avg salary per department
8. HAVING
What it is: Filters grouped data
What it does: Returns filtered groups
Query: Departments with avg salary > 40000
9. INNER JOIN
What it is: Combines matching rows from tables
What it does: Returns common data
Query: Employees with department names
10. LEFT JOIN
What it is: Combines all left + matching right
What it does: Returns all left table data
Query: All employees with departments
11. CASE WHEN
What it is: Conditional logic
What it does: Creates values based on condition
Query: Categorize salary
12. SUBQUERY
What it is: Query inside another query
What it does: Uses result of inner query
Query: Salary above average
13. RANK()
What it is: Window function
What it does: Assigns rank without grouping
Query: Rank employees by salary
14. DISTINCT
What it is: Removes duplicates
What it does: Returns unique values
Query: Unique departments
15. LIKE
What it is: Pattern matching
What it does: Filters text patterns
Query: Names starting with A
Double Tap β₯οΈ For More
1. SELECT
What it is: Used to choose columns from a table
What it does: Returns specific columns of data
Query: Fetch name and salary
SELECT name, salary
FROM employees;
2. FROM
What it is: Specifies the table
What it does: Tells SQL where to get data from
Query: Fetch all data from employees
SELECT *
FROM employees;
3. WHERE
What it is: Filters rows based on condition
What it does: Returns only matching rows
Query: Employees with salary > 30000
SELECT *
FROM employees
WHERE salary > 30000;
4. ORDER BY
What it is: Sorts the data
What it does: Arranges rows in order
Query: Sort by salary (highest first)
SELECT *
FROM employees
ORDER BY salary DESC;
5. COUNT()
What it is: Counts rows
What it does: Returns total records
Query: Count employees
SELECT COUNT(*)
FROM employees;
6. AVG()
What it is: Calculates average
What it does: Returns mean value
Query: Average salary
SELECT AVG(salary)
FROM employees;
7. GROUP BY
What it is: Groups rows by column
What it does: Applies aggregation per group
Query: Avg salary per department
SELECT department, AVG(salary)
FROM employees
GROUP BY department;
8. HAVING
What it is: Filters grouped data
What it does: Returns filtered groups
Query: Departments with avg salary > 40000
SELECT department, AVG(salary)
FROM employees
GROUP BY department
HAVING AVG(salary) > 40000;
9. INNER JOIN
What it is: Combines matching rows from tables
What it does: Returns common data
Query: Employees with department names
SELECT e.name, d.department_name
FROM employees e
INNER JOIN departments d
ON e.dept_id = d.dept_id;
10. LEFT JOIN
What it is: Combines all left + matching right
What it does: Returns all left table data
Query: All employees with departments
SELECT e.name, d.department_name
FROM employees e
LEFT JOIN departments d
ON e.dept_id = d.dept_id;
11. CASE WHEN
What it is: Conditional logic
What it does: Creates values based on condition
Query: Categorize salary
SELECT name,
CASE
WHEN salary > 40000 THEN 'High'
ELSE 'Low'
END AS category
FROM employees;
12. SUBQUERY
What it is: Query inside another query
What it does: Uses result of inner query
Query: Salary above average
SELECT name, salary
FROM employees
WHERE salary > (
SELECT AVG(salary)
FROM employees
);
13. RANK()
What it is: Window function
What it does: Assigns rank without grouping
Query: Rank employees by salary
SELECT name, salary,
RANK() OVER (ORDER BY salary DESC) AS rank
FROM employees;
14. DISTINCT
What it is: Removes duplicates
What it does: Returns unique values
Query: Unique departments
SELECT DISTINCT department
FROM employees;
15. LIKE
What it is: Pattern matching
What it does: Filters text patterns
Query: Names starting with A
SELECT *
FROM employees
WHERE name LIKE 'A%';
Double Tap β₯οΈ For More
β€20π3
Last Chance to Join π
Donβt miss this power-packed masterclass by Tushar Jha, Lead Data Scientist at Google.
Learn how FinTech leaders use data analytics to drive real growth with PW Skills.
β³ 2 Hours | High-Impact Learning
Secure your spot now before itβs gone - https://tinyurl.com/3dzsw8my
Donβt miss this power-packed masterclass by Tushar Jha, Lead Data Scientist at Google.
Learn how FinTech leaders use data analytics to drive real growth with PW Skills.
β³ 2 Hours | High-Impact Learning
Secure your spot now before itβs gone - https://tinyurl.com/3dzsw8my
β€2π1
Quick recap of essential SQL basics ππ
SQL is a domain-specific language used for managing and querying relational databases. It's crucial for interacting with databases, retrieving, storing, updating, and deleting data. Here are some fundamental SQL concepts:
1. Database
- A database is a structured collection of data. It's organized into tables, and SQL is used to manage these tables.
2. Table
- Tables are the core of a database. They consist of rows and columns, and each row represents a record, while each column represents a data attribute.
3. Query
- A query is a request for data from a database. SQL queries are used to retrieve information from tables. The SELECT statement is commonly used for this purpose.
4. Data Types
- SQL supports various data types (e.g., INTEGER, TEXT, DATE) to specify the kind of data that can be stored in a column.
5. Primary Key
- A primary key is a unique identifier for each row in a table. It ensures that each row is distinct and can be used to establish relationships between tables.
6. Foreign Key
- A foreign key is a column in one table that links to the primary key in another table. It creates relationships between tables in a database.
7. CRUD Operations
- SQL provides four primary operations for data manipulation:
- Create (INSERT) - Add new records to a table.
- Read (SELECT) - Retrieve data from one or more tables.
- Update (UPDATE) - Modify existing data.
- Delete (DELETE) - Remove records from a table.
8. WHERE Clause
- The WHERE clause is used in SELECT, UPDATE, and DELETE statements to filter and conditionally manipulate data.
9. JOIN
- JOIN operations are used to combine data from two or more tables based on a related column. Common types include INNER JOIN, LEFT JOIN, and RIGHT JOIN.
10. Index
- An index is a database structure that improves the speed of data retrieval operations. It's created on one or more columns in a table.
11. Aggregate Functions
- SQL provides functions like SUM, AVG, COUNT, MAX, and MIN for performing calculations on groups of data.
12. Transactions
- Transactions are sequences of one or more SQL statements treated as a single unit. They ensure data consistency by either applying all changes or none.
13. Normalization
- Normalization is the process of organizing data in a database to minimize data redundancy and improve data integrity.
14. Constraints
- Constraints (e.g., NOT NULL, UNIQUE, CHECK) are rules that define what data is allowed in a table, ensuring data quality and consistency.
Here is an amazing resources to learn & practice SQL: https://bit.ly/3FxxKPz
Share with credits: https://t.me/sqlspecialist
Hope it helps :)
SQL is a domain-specific language used for managing and querying relational databases. It's crucial for interacting with databases, retrieving, storing, updating, and deleting data. Here are some fundamental SQL concepts:
1. Database
- A database is a structured collection of data. It's organized into tables, and SQL is used to manage these tables.
2. Table
- Tables are the core of a database. They consist of rows and columns, and each row represents a record, while each column represents a data attribute.
3. Query
- A query is a request for data from a database. SQL queries are used to retrieve information from tables. The SELECT statement is commonly used for this purpose.
4. Data Types
- SQL supports various data types (e.g., INTEGER, TEXT, DATE) to specify the kind of data that can be stored in a column.
5. Primary Key
- A primary key is a unique identifier for each row in a table. It ensures that each row is distinct and can be used to establish relationships between tables.
6. Foreign Key
- A foreign key is a column in one table that links to the primary key in another table. It creates relationships between tables in a database.
7. CRUD Operations
- SQL provides four primary operations for data manipulation:
- Create (INSERT) - Add new records to a table.
- Read (SELECT) - Retrieve data from one or more tables.
- Update (UPDATE) - Modify existing data.
- Delete (DELETE) - Remove records from a table.
8. WHERE Clause
- The WHERE clause is used in SELECT, UPDATE, and DELETE statements to filter and conditionally manipulate data.
9. JOIN
- JOIN operations are used to combine data from two or more tables based on a related column. Common types include INNER JOIN, LEFT JOIN, and RIGHT JOIN.
10. Index
- An index is a database structure that improves the speed of data retrieval operations. It's created on one or more columns in a table.
11. Aggregate Functions
- SQL provides functions like SUM, AVG, COUNT, MAX, and MIN for performing calculations on groups of data.
12. Transactions
- Transactions are sequences of one or more SQL statements treated as a single unit. They ensure data consistency by either applying all changes or none.
13. Normalization
- Normalization is the process of organizing data in a database to minimize data redundancy and improve data integrity.
14. Constraints
- Constraints (e.g., NOT NULL, UNIQUE, CHECK) are rules that define what data is allowed in a table, ensuring data quality and consistency.
Here is an amazing resources to learn & practice SQL: https://bit.ly/3FxxKPz
Share with credits: https://t.me/sqlspecialist
Hope it helps :)
β€3
π₯ Top SQL Projects for Data Analytics π
If you're preparing for a Data Analyst role or looking to level up your SQL skills, working on real-world projects is the best way to learn!
Here are some must-do SQL projects to strengthen your portfolio. π
π’ Beginner-Friendly SQL Projects (Great for Learning Basics)
β Employee Database Management β Build and query HR data π
β Library Book Tracking β Create a database for book loans and returns
β Student Grading System β Analyze student performance data
β Retail Point-of-Sale System β Work with sales and transactions π°
β Hotel Booking System β Manage customer bookings and check-ins π¨
π‘ Intermediate SQL Projects (For Stronger Querying & Analysis)
β‘ E-commerce Order Management β Analyze order trends & customer data π
β‘ Sales Performance Analysis β Work with revenue, profit margins & KPIs π
β‘ Inventory Control System β Optimize stock tracking π¦
β‘ Real Estate Listings β Manage and analyze property data π‘
β‘ Movie Rating System β Analyze user reviews & trends π¬
π΅ Advanced SQL Projects (For Business-Level Analytics)
πΉ Social Media Analytics β Track user engagement & content trends
πΉ Insurance Claim Management β Fraud detection & risk assessment
πΉ Customer Feedback Analysis β Perform sentiment analysis on reviews β
πΉ Freelance Job Platform β Match freelancers with project opportunities
πΉ Pharmacy Inventory System β Optimize stock levels & prescriptions
π΄ Expert-Level SQL Projects (For Data-Driven Decision Making)
π₯ Music Streaming Analysis β Study user behavior & song trends πΆ
π₯ Healthcare Prescription Tracking β Identify patterns in medicine usage
π₯ Employee Shift Scheduling β Optimize workforce efficiency β³
π₯ Warehouse Stock Control β Manage supply chain data efficiently
π₯ Online Auction System β Analyze bidding patterns & sales performance ποΈ
π Pro Tip: If you're applying for Data Analyst roles, pick 3-4 projects, clean the data, and create interactive dashboards using Power BI/Tableau to showcase insights!
React with β₯οΈ if you want detailed explanation of each project
Share with credits: π https://t.me/sqlspecialist
Hope it helps :)
If you're preparing for a Data Analyst role or looking to level up your SQL skills, working on real-world projects is the best way to learn!
Here are some must-do SQL projects to strengthen your portfolio. π
π’ Beginner-Friendly SQL Projects (Great for Learning Basics)
β Employee Database Management β Build and query HR data π
β Library Book Tracking β Create a database for book loans and returns
β Student Grading System β Analyze student performance data
β Retail Point-of-Sale System β Work with sales and transactions π°
β Hotel Booking System β Manage customer bookings and check-ins π¨
π‘ Intermediate SQL Projects (For Stronger Querying & Analysis)
β‘ E-commerce Order Management β Analyze order trends & customer data π
β‘ Sales Performance Analysis β Work with revenue, profit margins & KPIs π
β‘ Inventory Control System β Optimize stock tracking π¦
β‘ Real Estate Listings β Manage and analyze property data π‘
β‘ Movie Rating System β Analyze user reviews & trends π¬
π΅ Advanced SQL Projects (For Business-Level Analytics)
πΉ Social Media Analytics β Track user engagement & content trends
πΉ Insurance Claim Management β Fraud detection & risk assessment
πΉ Customer Feedback Analysis β Perform sentiment analysis on reviews β
πΉ Freelance Job Platform β Match freelancers with project opportunities
πΉ Pharmacy Inventory System β Optimize stock levels & prescriptions
π΄ Expert-Level SQL Projects (For Data-Driven Decision Making)
π₯ Music Streaming Analysis β Study user behavior & song trends πΆ
π₯ Healthcare Prescription Tracking β Identify patterns in medicine usage
π₯ Employee Shift Scheduling β Optimize workforce efficiency β³
π₯ Warehouse Stock Control β Manage supply chain data efficiently
π₯ Online Auction System β Analyze bidding patterns & sales performance ποΈ
π Pro Tip: If you're applying for Data Analyst roles, pick 3-4 projects, clean the data, and create interactive dashboards using Power BI/Tableau to showcase insights!
React with β₯οΈ if you want detailed explanation of each project
Share with credits: π https://t.me/sqlspecialist
Hope it helps :)
β€3
SQL From Basic to Advanced level
Basic SQL is ONLY 7 commands:
- SELECT
- FROM
- WHERE (also use SQL comparison operators such as =, <=, >=, <> etc.)
- ORDER BY
- Aggregate functions such as SUM, AVERAGE, COUNT etc.
- GROUP BY
- CREATE, INSERT, DELETE, etc.
You can do all this in just one morning.
Once you know these, take the next step and learn commands like:
- LEFT JOIN
- INNER JOIN
- LIKE
- IN
- CASE WHEN
- HAVING (undertstand how it's different from GROUP BY)
- UNION ALL
This should take another day.
Once both basic and intermediate are done, start learning more advanced SQL concepts such as:
- Subqueries (when to use subqueries vs CTE?)
- CTEs (WITH AS)
- Stored Procedures
- Triggers
- Window functions (LEAD, LAG, PARTITION BY, RANK, DENSE RANK)
These can be done in a couple of days.
Learning these concepts is NOT hard at all
- what takes time is practice and knowing what command to use when. How do you master that?
- First, create a basic SQL project
- Then, work on an intermediate SQL project (search online) -
Lastly, create something advanced on SQL with many CTEs, subqueries, stored procedures and triggers etc.
This is ALL you need to become a badass in SQL, and trust me when I say this, it is not rocket science. It's just logic.
Remember that practice is the key here. It will be more clear and perfect with the continous practice
Best telegram channel to learn SQL: https://t.me/sqlanalyst
Data Analyst Jobsπ
https://t.me/jobs_SQL
Join @free4unow_backup for more free resources.
Like this post if it helps πβ€οΈ
ENJOY LEARNING ππ
Basic SQL is ONLY 7 commands:
- SELECT
- FROM
- WHERE (also use SQL comparison operators such as =, <=, >=, <> etc.)
- ORDER BY
- Aggregate functions such as SUM, AVERAGE, COUNT etc.
- GROUP BY
- CREATE, INSERT, DELETE, etc.
You can do all this in just one morning.
Once you know these, take the next step and learn commands like:
- LEFT JOIN
- INNER JOIN
- LIKE
- IN
- CASE WHEN
- HAVING (undertstand how it's different from GROUP BY)
- UNION ALL
This should take another day.
Once both basic and intermediate are done, start learning more advanced SQL concepts such as:
- Subqueries (when to use subqueries vs CTE?)
- CTEs (WITH AS)
- Stored Procedures
- Triggers
- Window functions (LEAD, LAG, PARTITION BY, RANK, DENSE RANK)
These can be done in a couple of days.
Learning these concepts is NOT hard at all
- what takes time is practice and knowing what command to use when. How do you master that?
- First, create a basic SQL project
- Then, work on an intermediate SQL project (search online) -
Lastly, create something advanced on SQL with many CTEs, subqueries, stored procedures and triggers etc.
This is ALL you need to become a badass in SQL, and trust me when I say this, it is not rocket science. It's just logic.
Remember that practice is the key here. It will be more clear and perfect with the continous practice
Best telegram channel to learn SQL: https://t.me/sqlanalyst
Data Analyst Jobsπ
https://t.me/jobs_SQL
Join @free4unow_backup for more free resources.
Like this post if it helps πβ€οΈ
ENJOY LEARNING ππ
β€9
Data Analyst INTERVIEW QUESTIONS AND ANSWERS
ππ
1.Can you name the wildcards in Excel?
Ans: There are 3 wildcards in Excel that can ve used in formulas.
Asterisk (*) β 0 or more characters. For example, Ex* could mean Excel, Extra, Expertise, etc.
Question mark (?) β Represents any 1 character. For example, R?ain may mean Rain or Ruin.
Tilde (~) β Used to identify a wildcard character (~, *, ?). For example, If you need to find the exact phrase India* in a list. If you use India* as the search string, you may get any word with India at the beginning followed by different characters (such as Indian, Indiana). If you have to look for Indiaβ exclusively, use ~.
Hence, the search string will be india~*. ~ is used to ensure that the spreadsheet reads the following character as is, and not as a wildcard.
2.What is cascading filter in tableau?
Ans: Cascading filters can also be understood as giving preference to a particular filter and then applying other filters on previously filtered data source. Right-click on the filter you want to use as a main filter and make sure it is set as all values in dashboard then select the subsequent filter and select only relevant values to cascade the filters. This will improve the performance of the dashboard as you have decreased the time wasted in running all the filters over complete data source.
3.What is the difference between .twb and .twbx extension?
Ans:
A .twb file contains information on all the sheets, dashboards and stories, but it wonβt contain any information regarding data source. Whereas .twbx file contains all the sheets, dashboards, stories and also compressed data sources. For saving a .twbx extract needs to be performed on the data source. If we forward .twb file to someone else than they will be able to see the worksheets and dashboards but wonβt be able to look into the dataset.
4.What are the various Power BI versions?
Power BI Premium capacity-based license, for example, allows users with a free license to act on content in workspaces with Premium capacity. A user with a free license can only use the Power BI service to connect to data and produce reports and dashboards in My Workspace outside of Premium capacity. They are unable to exchange material or publish it in other workspaces. To process material, a Power BI license with a free or Pro per-user license only uses a shared and restricted capacity. Users with a Power BI Pro license can only work with other Power BI Pro users if the material is stored in that shared capacity. They may consume user-generated information, post material to app workspaces, share dashboards, and subscribe to dashboards and reports. Pro users can share material with users who donβt have a Power BI Pro subscription while workspaces are at Premium capacity.
ENJOY LEARNING ππ
ππ
1.Can you name the wildcards in Excel?
Ans: There are 3 wildcards in Excel that can ve used in formulas.
Asterisk (*) β 0 or more characters. For example, Ex* could mean Excel, Extra, Expertise, etc.
Question mark (?) β Represents any 1 character. For example, R?ain may mean Rain or Ruin.
Tilde (~) β Used to identify a wildcard character (~, *, ?). For example, If you need to find the exact phrase India* in a list. If you use India* as the search string, you may get any word with India at the beginning followed by different characters (such as Indian, Indiana). If you have to look for Indiaβ exclusively, use ~.
Hence, the search string will be india~*. ~ is used to ensure that the spreadsheet reads the following character as is, and not as a wildcard.
2.What is cascading filter in tableau?
Ans: Cascading filters can also be understood as giving preference to a particular filter and then applying other filters on previously filtered data source. Right-click on the filter you want to use as a main filter and make sure it is set as all values in dashboard then select the subsequent filter and select only relevant values to cascade the filters. This will improve the performance of the dashboard as you have decreased the time wasted in running all the filters over complete data source.
3.What is the difference between .twb and .twbx extension?
Ans:
A .twb file contains information on all the sheets, dashboards and stories, but it wonβt contain any information regarding data source. Whereas .twbx file contains all the sheets, dashboards, stories and also compressed data sources. For saving a .twbx extract needs to be performed on the data source. If we forward .twb file to someone else than they will be able to see the worksheets and dashboards but wonβt be able to look into the dataset.
4.What are the various Power BI versions?
Power BI Premium capacity-based license, for example, allows users with a free license to act on content in workspaces with Premium capacity. A user with a free license can only use the Power BI service to connect to data and produce reports and dashboards in My Workspace outside of Premium capacity. They are unable to exchange material or publish it in other workspaces. To process material, a Power BI license with a free or Pro per-user license only uses a shared and restricted capacity. Users with a Power BI Pro license can only work with other Power BI Pro users if the material is stored in that shared capacity. They may consume user-generated information, post material to app workspaces, share dashboards, and subscribe to dashboards and reports. Pro users can share material with users who donβt have a Power BI Pro subscription while workspaces are at Premium capacity.
ENJOY LEARNING ππ
β€4
β
Basic SQL Queries Interview Questions With Answers π₯οΈ
1. What does SELECT do
β SELECT fetches data from a table
β You choose columns you want to see
Example: SELECT name, salary FROM employees;
2. What does FROM do
β FROM tells SQL where data lives
β It specifies the table name
Example: SELECT * FROM customers;
3. What is WHERE clause
β WHERE filters rows
β It runs before aggregation
Example: SELECT * FROM orders WHERE status = 'Delivered';
4. Difference between WHERE and HAVING
β WHERE filters rows before GROUP BY
β HAVING filters groups after aggregation
Example: WHERE filters orders, HAVING filters total_sales
5. How do you sort data
β Use ORDER BY
β Default order is ASC
Example: SELECT * FROM employees ORDER BY salary DESC;
6. How do you sort by multiple columns
β SQL sorts left to right
Example: SELECT * FROM students ORDER BY class ASC, marks DESC;
7. What is LIMIT
β LIMIT restricts number of rows returned
β Useful for top N queries
Example: SELECT * FROM products LIMIT 5;
8. What is OFFSET
β OFFSET skips rows
β Used with LIMIT for pagination
Example: SELECT * FROM products LIMIT 5 OFFSET 10;
9. How do you filter on multiple conditions
β Use AND, OR
Example: SELECT * FROM users WHERE city = 'Delhi' AND age > 25;
10. Difference between AND and OR
β AND needs all conditions true
β OR needs one condition true
Quick interview advice
β’ Always say execution order: FROM β WHERE β SELECT β ORDER BY β LIMIT
β’ Write clean examples
β’ Speak logic first, syntax nextΒΉ
Double Tap β€οΈ For More
1. What does SELECT do
β SELECT fetches data from a table
β You choose columns you want to see
Example: SELECT name, salary FROM employees;
2. What does FROM do
β FROM tells SQL where data lives
β It specifies the table name
Example: SELECT * FROM customers;
3. What is WHERE clause
β WHERE filters rows
β It runs before aggregation
Example: SELECT * FROM orders WHERE status = 'Delivered';
4. Difference between WHERE and HAVING
β WHERE filters rows before GROUP BY
β HAVING filters groups after aggregation
Example: WHERE filters orders, HAVING filters total_sales
5. How do you sort data
β Use ORDER BY
β Default order is ASC
Example: SELECT * FROM employees ORDER BY salary DESC;
6. How do you sort by multiple columns
β SQL sorts left to right
Example: SELECT * FROM students ORDER BY class ASC, marks DESC;
7. What is LIMIT
β LIMIT restricts number of rows returned
β Useful for top N queries
Example: SELECT * FROM products LIMIT 5;
8. What is OFFSET
β OFFSET skips rows
β Used with LIMIT for pagination
Example: SELECT * FROM products LIMIT 5 OFFSET 10;
9. How do you filter on multiple conditions
β Use AND, OR
Example: SELECT * FROM users WHERE city = 'Delhi' AND age > 25;
10. Difference between AND and OR
β AND needs all conditions true
β OR needs one condition true
Quick interview advice
β’ Always say execution order: FROM β WHERE β SELECT β ORDER BY β LIMIT
β’ Write clean examples
β’ Speak logic first, syntax nextΒΉ
Double Tap β€οΈ For More
β€6