'Query to Return all Working Periods per Employee and Cost Code

I have data showing employee, cost code and WeekEnd (Sunday). WeekEnd is the last day of working week, from Monday thru Sunday:

EmpID   CostCode   WeekEnd
=============================
    1   1          01/02/2022  
    1   1          01/09/2022
    Employee skipped working in week of 1/16/2022 ...
    1   1          01/23/2022
    1   1          01/30/2022
    1   2          02/06/2022 
    1   3          02/13/2022
    1   3          02/20/2022

Need to get result like this:

EmpID   CostCode   FirstWeekEnd    LastWeekEnd
==============================================
    1   1          01/02/2022      01/09/2022
    1   1          01/23/2022      01/30/2022
    1   2          02/06/2022      02/06/2022
    1   3          02/13/2022      02/20/2022

I need to get all periods (start - end) when employee worked per cost code?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source