The Project Employees II SQL problem asks you to find the project(s) with the most employees. If there's a tie, return all tied projects. This easy SQL problem tests GROUP BY, COUNT, and then finding the maximum count. The database interview pattern is demonstrated.
Meta asks this as a "find max group" SQL problem — requiring two steps: count per group, then filter for the maximum count. It tests the HAVING with subquery pattern or dense rank approach.
COUNT + subquery for max. SELECT project_id FROM Project GROUP BY project_id HAVING COUNT(employee_id) = (SELECT COUNT(employee_id) FROM Project GROUP BY project_id ORDER BY COUNT(employee_id) DESC LIMIT 1).
Or: SELECT project_id FROM Project GROUP BY project_id HAVING COUNT(*) >= ALL (SELECT COUNT(*) FROM Project GROUP BY project_id).
Project: proj1 has 3 employees, proj2 has 3 employees, proj3 has 1 employee. Max employee count = 3. Projects with 3: proj1, proj2. Result: [proj1, proj2].
"Find group with max aggregate" requires a two-step approach: (1) compute aggregate per group, (2) filter for max. The HAVING + max subquery pattern handles ties correctly. Alternative: DENSE_RANK() OVER (ORDER BY COUNT DESC) WHERE rank=1. Always consider ties in "find maximum" SQL problems. Practice: "products with highest sales," "categories with most items," "months with peak activity."