SQL
FOR BUSINESS ANALYST
Business Analyst takeaway:
SQL enables requirement validation, KPI tracking,
stakeholder reporting, gap analysis, and data-
driven decision-making.
LIST OF QUERIES
SQL Query / Concept Business Use Case Example
SELECT customer_id, city FROM
SELECT Retrieve required data fields
customers;
SELECT * FROM orders WHERE
WHERE Filter data for analysis
status='Completed';
SELECT DISTINCT product_category
DISTINCT Identify unique values
FROM products;
SELECT * FROM sales ORDER BY
ORDER BY Rank or sort data
revenue DESC;
SELECT * FROM customers ORDER
LIMIT / TOP View top or recent records
BY signup_date DESC LIMIT 10;
COUNT Measure volume / demand SELECT COUNT(*) FROM orders;
SELECT SUM(order_amount) FROM
SUM Calculate total revenue / cost
orders;
SELECT AVG(order_amount) FROM
AVG Track average KPIs
orders;
SELECT MAX(order_amount) FROM
MIN / MAX Identify extremes
orders;
SELECT city, COUNT(*) FROM
GROUP BY Segment data for reporting
customers GROUP BY city;
SELECT city, COUNT(*) FROM
HAVING Filter aggregated results
customers GROUP BY city HAVING
COUNT(*) > 100;
SELECT o.order_id,
INNER JOIN Combine related datasets
c.customer_name FROM orders o
JOIN c stomers c ON
SELECT c.customer_name,
LEFT JOIN Identify missing records
o.order_id FROM customers c LEFT
JOIN orders o ON
CASE WHEN order_amount>10000
CASE WHEN Apply business rules
THEN 'High Value' ELSE 'Regular'
END
WHERE order_date BETWEEN '2025-
BETWEEN Date or range analysis
01-01' AND '2025-01-31';
WHERE city IN
IN Filter using multiple values
('Chennai','Bangalore');
LIKE Pattern matching WHERE email LIKE '%@[Link]';
WHERE order_amount > (SELECT
Subquery Advanced insights
AVG(order_amount) FROM orders);
WITH sales AS (...) SELECT * FROM
CTE (WITH) Complex, readable analysis
sales;