Here is the employee table with start and end date of his assignments
| PS_CTS_IQN_CWR_DTL | | |
| accrual_year | period | emplid | start_date | end_date |
| 2019 | 7 | 787309 | 1-Jul-19 | 31-Jul-19 |
| 2019 | 7 | 787310 | 1-Jul-19 | 31-Jul-19 |
| 2019 | 7 | 787311 | 1-Jul-19 | 3-Jul-19 |
| 2019 | 7 | 787311 | 10-Jul-19 | 31-Jul-19 |
| 2019 | 7 | 787404 | 1-Jul-19 | 23-Jul-19 |
| 2019 | 7 | 787406 | 1-Jul-19 | 31-Jul-19 |
| 2019 | 7 | 787407 | 1-Jul-19 | 28-Jul-19 |
| 2019 | 7 | 787407 | 29-Jul-19 | 31-Jul-19 |
Here is the table with period end date
| ps_CTS_IQN_PRD_TBL |
| period | year | period_end_date |
| 7 | 2019 | 5-Jul-19 |
| 7 | 2019 | 12-Jul-19 |
| 7 | 2019 | 19-Jul-19 |
| 7 | 2019 | 26-Jul-19 |
| 7 | 2019 | 2-Aug-19 |
need to count active days(only working days which should not include Saturday and Sunday) of each employee for each period for month of July (1st to 31st July). query should return us as given below
| 5-Jul-19 | 12-Jul-19 | 19-Jul-19 | 26-Jul-19 | 2-Aug-19 |
| 787309 | 5 | 5 | 5 | 5 | 3 |
| 787310 | 5 | 5 | 5 | 5 | 3 |
| 787311 | 3 | 3 | 5 | 5 | 3 |
| 787404 | 5 | 5 | 5 | 5 | 3 |
| 787406 | 5 | 5 | 5 | 5 | 3 |
| 787407 | 5 | 5 | 5 | 5 | 3 |
| | | | | |