Here is my query. I need to return all active drivers for that month for each day even if for that day they did not transport someone. So someone may transport a patient today but may be off tomorrow and won't transport tomorrow. So for today driver 1 should in query for X number of transports but for tomorrow driver 1 should show in query for 0 number of transports. How is that possible with mysql?
- schedule table provides information about the appointment
- vehicle_driver table provides information about the providers(drivers) assigned to different vehicles for that day
- drivers is like an employee table with driver information.
here's the query
Select date_format(Date,'%d') as date,
concat(FirstName, ' ', LastName) as name, count(ScheduleID)
schedule,vehicle_driver, drivers
where schedule.crewunit = vehicle_driver.id
and Driver_ID IN (vehicle_driver.provider1, vehicle_driver.provider2)
and schedule.Date between DATE_SUB(CURRENT_DATE, INTERVAL DAYOFMONTH(CURRENT_DATE)-1 DAY) and CURRENT_DATE)
and schedule.activityStatus = 0
group_by schedule.Date, name ASC
order_by trans_schedule.Date ASC
Here's some more information....
Here's what the table results are (I only included it for 11/1/2018):
date name Trips
1 Ashley 4
1 Bruce 6
1 Carlos 16
1 Charles 4
1 Charles 4
1 Curtis 4
1 Frances 7
1 Garrick 4
1 James 6
1 Janet 5
1 Katherine 4
1 Kim 13
1 Mark 2
1 Ronnie 15
1 stuart 5
I'd like for it to give me results like this:
1 Ashley 4
1 Bruce 6
1 Carlos 16
1 Charles 4
1 Charles 4
**1 Chris 0**
1 Curtis 4
1 Darrell 0
1 Frances 7
1 Garrick 4
**1 Heath 0**
1 James 6
1 Janet 5
**1 Joseph 0
1 Katelyn 0**
1 Katherine 4
1 Kim 13
**1 Linzie 0**
1 Mark 2
**1 Roger 0**
1 Ronnie 15
**1 Ryan 0**
1 stuart 5
**1 Tiffany 0**