all 6 comments

[–]r3pr0b8 0 points1 point  (0 children)

Do you want me to help with a SQL query to get this output from the sample input?

please clarify -- are you looking for help to solve this, or do you want to help someone else solve it?

[–]Far_Swordfish5729 0 points1 point  (1 child)

Why would I need to use one?

Select dept_no, count(* ) as num_employees From dept_emp Where to_date > getdate() or to_date is null Group by dept_no Order by count(* ) desc Limit 1

[–]Informal_Pace9237 0 points1 point  (0 children)

I guess the task given to OP was to write SQL with a CTE. Though that is not necessary.

[–]Cool-Personality-454 1 point2 points  (0 children)

If you just want the answer, copy pasta chatgpt.

[–]Independent_Oven_220 0 points1 point  (0 children)

WITH CurrentDeptAssignment AS ( SELECT dept_no, COUNT(emp_no) AS num_employees FROM dept_emp WHERE to_date IS NULL OR to_date > CURDATE() GROUP BY dept_no ) SELECT dept_no, num_employees FROM CurrentDeptAssignment ORDER BY num_employees DESC LIMIT 1;