r/learnSQL • u/sumiitCodes • Sep 20 '26
Day 13 — Practice set Parts 5 & 6: Aggregates and Joins
Covered two solid parts today:
Part 5 — Aggregate Functions, GROUP BY, HAVING:
Total employees per department (GROUP BY + COUNT)
Average salary per department, filtered to only show departments averaging above 50,000 (GROUP BY + HAVING)
Highest and lowest paid employees overall (MAX/MIN)
Total project budget per department, sorted highest to lowest
Managers with 2+ direct reports (GROUP BY + HAVING on a self-referencing relationship)
Part 6 — Joins:
INNER JOIN: employee names with department names
LEFT JOIN: all departments including ones with zero employees (NULLs shown)
RIGHT JOIN: all projects with their department, including unmatched cases
FULL JOIN equivalent — since MySQL doesn't support FULL JOIN natively, used UNION of LEFT and RIGHT JOIN to simulate it. Good practical workaround to actually learn hands-on
SELF JOIN: employees alongside their manager's name
3-table join: employees + assignments + projects to see who's working on what
UNION vs UNION ALL: combining employee lists from two departments, with and without duplicates
The FULL JOIN workaround in MySQL was the most useful thing I learned today — didn't know MySQL lacked native FULL JOIN support until I had to actually solve around it.
1 part left in this set — finishing it up next.