Join our telegram channel to learn how data analysis can reveal fascinating patterns, trends, and stories hidden within the numbers! π
For ads & suggestions: @love_data
Post #1965
2.05K
β
SQL Interview Challenge πΌπ§
ππ»ππ²πΏππΆπ²ππ²πΏ: How would you count how many employees are in each department?
π π²: Iβd use the
πΉ Query:
β Why it works:
β
β
β Clean, scalable, and works with large datasets
π Bonus Insight:
To filter only departments with more than 5 employees:
β
β Useful in dashboards, reports, and business logic
π¬ Tap β€οΈ for more SQL interview tips!
ππ»ππ²πΏππΆπ²ππ²πΏ: How would you count how many employees are in each department?
π π²: Iβd use the
GROUP BY clause with COUNT(*) to aggregate employee counts per department.πΉ Query:
SELECT department, COUNT(*) AS employee_count
FROM employees
GROUP BY department;
β Why it works:
β
GROUP BY groups rows by department β
COUNT(*) counts employees in each group β Clean, scalable, and works with large datasets
π Bonus Insight:
To filter only departments with more than 5 employees:
SELECT department, COUNT(*) AS employee_count
FROM employees
GROUP BY department
HAVING COUNT(*) > 5;
β
HAVING filters aggregated results β Useful in dashboards, reports, and business logic
π¬ Tap β€οΈ for more SQL interview tips!
- β€ 7


