Loading…
HR wants a headcount table for 2024 and 2025 with one row per quarter end. There is no history table to read it from: each employment record has a start date, an end date if the person has left, and the status as it is today.
Return snapshot_date (the last day of each quarter from 2024-03-31 to 2025-12-31), headcount (records with on or before the snapshot date and either empty or after it), (records with from the first day of the quarter through the snapshot date), and (records with from the first day of the quarter through the snapshot date). Order by .
started_atended_athired_in_quarterstarted_atleft_in_quarterended_atsnapshot_dateCreate a free account to save your progress and reveal the worked answer for this free exercise. The complete practice library is available with Practice Pass or Mastery.