I have two tables user and attendance. I want to get attendance for all users within specific time interval even though users doesn't have attendance on some dates like public holidays, ...
I used generate_series to get all dates but when joining and grouping i get only single value for dates with no attendance.
User table:
id | name | phone
1 | arun | 123456
2 | jack | 098765
Attendance table:
id | user_id | ckeck_in | check_out
11 | 2 | 2021-12-30 07:30:00 | 2021-12-30 16:00:00
21 | 1 | 2021-12-28 09:18:00 | 2021-12-28 17:45:00
so if i need to get all user attendance for the month of dec-2021, i want it like this
final_result:
user_id | name | date | check_in | check_out
1 | arun | 2021-12-01 | null | null
2 | jack | 2021-12-01 | null | null
1 | arun | 2021-12-02 | null | null
2 | jack | 2021-12-02 | null | null
...
1 | arun | 2021-12-28 | 2021-12-28 09:18:00 | 2021-12-28 17:45:00
2 | jack | 2021-12-28 | null | null
...
1 | arun | 2021-12-30 | null | null
2 | jack | 2021-12-30 | 2021-12-30 07:30:00 | 2021-12-30 16:00:00
PS: One user can have multiple check_in and check_out in a day.
Thanks in advance!