Longest time away from the office

HardMicrosoftlagduplicatesgaps· 40 XP

Microsoft's workplace team wants to reach out to people who have been away from the office for a long stretch.

For each employee, find the longest gap in calendar days between two consecutive office days (a gap from Friday to Monday is 3 days). Show the 5 employees with the longest gap.

Expected output

  • Longest first; break ties with the smaller emp_id; exactly 5 rows

Example of the shape (made-up values):

emp_id longest_gap_days
42 23

Hints, the later steps and the answer come with Pro.

Write your query here. Ctrl + Enter submits.