I have this query. I want to display the count of each shifts then I wrote the query like this:
SELECT count(checkups_id) as checkup_count, shifts.description, shifts.shifts_id
from checkups
right join shifts on shifts.shifts_id=checkups.shifts_id
group by shifts.shifts_id
Result:
| checkup_count | description | shifts_id | 
|---|---|---|
| 4 | Morning Shift | 1 | 
| 7 | Afternoon Shift | 2 | 
But then I want to display the current date checkup_count using where date like this:
SELECT count(checkups_id) as checkup_count, shifts.description, shifts.shifts_id
from checkups
right join shifts on shifts.shifts_id=checkups.shifts_id
where date(checkups.created_at) = '2021-09-13'
group by shifts.shifts_id
Result:
| checkup_count | description | shifts_id | 
|---|---|---|
| 2 | Morning Shift | 1 | 
I need to get the Afternoon Shift checkup_count (which is currently 0), so what I want to do is to display the result like this:
| checkup_count | description | shifts_id | 
|---|---|---|
| 2 | Morning Shift | 1 | 
| 0 | Afternoon Shift | 2 | 
How do I write the query?
 
     
    