I'm pretty new to mysql and I have this SQL here:
SELECT * , MAX(meeting_date) AS recent_meeting_date
FROM driver
INNER JOIN meeting_attendee ON meeting_attendee.attendee_email = driver.driver_email
INNER JOIN meeting ON meeting.meeting_id = meeting_attendee.meeting_id
WHERE recent_meeting_date < UTC_TIMESTAMP
GROUP BY driver_id
ORDER BY driver_id;
I have a driver
table with drivers details and inner joins from meeting
table where there's a list of all meetings and their and meeting_attendee
table where there's a list of all drivers attended meetings in the past and future.
I need to have a sql that shows a list of all drivers who haven't booked a meeting yet, means that their recent meeting date is less than today's date and NO greater than today's date.
This sql doesn't run because we can't use recent_meeting_date
in a WHERE clause. How can I fix the sql to make it work?