This counts how many employees are in each department.
SELECT department, COUNT(*) AS employee_count
FROM employees
GROUP BY department;This calculates the average price per product category.
SELECT category, AVG(price) AS avg_price
FROM products
GROUP BY category;Groups data by both department and role.
SELECT department, role, COUNT(*) AS count
FROM employees
GROUP BY department, role;Sorts departments by employee count in descending order.
SELECT department, COUNT(*) AS total
FROM employees
GROUP BY department
ORDER BY total DESC;Only shows departments with more than 10 employees.
SELECT department, COUNT(*) AS total
FROM employees
GROUP BY department
HAVING total > 10;HAVING for filtering aggregated resultsAsk the AI if you need help understanding or want to dive deeper in any topic