/*
Alias: WORK
LiveAnswer: FALSE

*/

SELECT Appointments."Date", Appointments.DocID, Appointments.Duration, Appointments.StartTime,
		 CAST(SUBSTRING(Appointments.StartTime FROM 1 FOR 2) AS INT)*60 + 
					CAST(SUBSTRING(Appointments.StartTime FROM 6 FOR 2) AS INT) AS StartMin,
		 Appointments.PatName, Appointments.Details,
		 Doctors.LastName AS Doctor
FROM Appointments LEFT OUTER JOIN Doctors 
							 ON Appointments.DocID = Doctors.DocID
WHERE CAST(SUBSTRING(Appointments.StartTime FROM 1 FOR 2) AS INT) >= 10
UNION
SELECT Appointments."Date", Appointments.DocID, Appointments.Duration, Appointments.StartTime,
		 CAST(SUBSTRING(Appointments.StartTime FROM 1 FOR 2) AS INT)*60 + 
					CAST(SUBSTRING(Appointments.StartTime FROM 5 FOR 2) AS INT) AS StartMin,
		 Appointments.PatName, Appointments.Details,
		 Doctors.LastName AS Doctor
FROM Appointments LEFT OUTER JOIN Doctors 
							 ON Appointments.DocID = Doctors.DocID
WHERE CAST(SUBSTRING(Appointments.StartTime FROM 1 FOR 2) AS INT) < 10
