TGViewer
Data Analytics Data Analytics @sqlspecialist ยท 111K subscribers
Post #2345 5.18K
๐Ÿ“Š ๐—œ๐—ป๐˜๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฒ๐˜„๐—ฒ๐—ฟ: How do you get the Employee Count by Department in SQL?

๐Ÿ™‹โ€โ™‚๏ธ ๐— ๐—ฒ: Use GROUP BY to aggregate employees per department:

SELECT department_id, COUNT(*) AS employee_count
FROM employees
GROUP BY department_id;

๐Ÿง  Logic Breakdown:

COUNT(*) counts employees in each department

GROUP BY department_id groups rows by department


โœ… Use Case: Department sizing, HR analytics, resource allocation

๐Ÿ’ก Pro Tip: Add ORDER BY employee_count DESC to see the largest departments first.

๐Ÿ’ฌ Tap โค๏ธ for more!
  • โค 6
  • ๐Ÿ‘ 1
  • ๐Ÿ‘ 1
More from @sqlspecialist
  1. Oct 14, 2026I could then categorize customers into groups such as Active, At Risk, and Inactive and suโ€ฆ
  2. Oct 14, 2026๐Ÿ“Š Data Analyst Interview Series โ€” Part 10 Guys, let's continue our Data Analyst Interviewโ€ฆ
  3. Oct 13, 2026๐Ÿ“Š Data Analyst Interview Series โ€” Part 9 Guys, let's continue our Data Analyst Interviewโ€ฆ
  4. Oct 13, 2026๐—ง๐—ข๐—ฃ ๐—™๐—ฅ๐—˜๐—˜ ๐—–๐—ข๐—จ๐—ฅ๐—ฆ๐—˜๐—ฆ ๐—ง๐—ข ๐—•๐—ข๐—ข๐—ฆ๐—ง ๐—ฌ๐—ข๐—จ๐—ฅ ๐—ฆ๐—ž๐—œ๐—Ÿ๐—Ÿ๐—ฆ ๐—œ๐—ก ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ! Explorโ€ฆ
  5. Oct 12, 20268๏ธโƒฃ You receive a dataset with inconsistent date formats. How would you clean it? Sample Aโ€ฆ
  6. Oct 12, 2026๐Ÿ“Š Data Analyst Interview Series โ€” Part 7 Guys, let's continue our Data Analyst Interviewโ€ฆ
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’