Module 03

Grouping & Business KPIs

Aggregate transactional rows into analytical dashboards and isolate specific group sectors cleanly.

📋 Source Dataset (4 Sample Records)

namedepartmentsalarycity
AmitTech80000Noida
RohanHR55000Mumbai
NehaTech90000Noida
VikramHR60000Noida

1. COUNT & AVG Functions

Definition: COUNT tallies total logged profiles while AVG calculates the numerical mathematical mean within grouped segments.

SELECT department, COUNT(*) AS emp_count, AVG(salary) AS avg_sal 
FROM employees 
GROUP BY department;
departmentemp_countavg_sal
Tech285000
HR257500

2. SUM & MAX Aggregations

Definition: SUM calculates full financial expense pipelines, while MAX extracts peak values per sector group.

SELECT city, SUM(salary) AS total_budget, MAX(salary) AS max_sal 
FROM employees 
GROUP BY city;
citytotal_budgetmax_sal
Noida23000090000
Mumbai5500055000

3. HAVING Filter Clause

Definition: Evaluates filter logic strictly after aggregation groups are built (since WHERE cannot handle summary functions).

SELECT department, AVG(salary) AS average_salary 
FROM employees 
GROUP BY department 
HAVING AVG(salary) > 70000;
departmentaverage_salary
Tech85000

Unlock Real Corporate Scenario Interactive Sandboxes

Basic structures are covered! To clear FAANG, MAANG & top analytical enterprise interviews, buy the complete pack to get 150+ interactive practice question sheets, video explanation keys, and real production datasets.