I am using a number of select statements to drive results, however I have 2 select statements which returns the minimum time for appointment and max time for appointment. However where the min and max are the same, I want to remove from within my where clause.
SELECT
APPOINTMENTS.userid,
users.LOCATIONID,
MIN(APPOINTMENTTIME) AS mintime,
MAX(APPOINTMENTTIME) AS maxtime
FROM appointments
WHERE APPOINTMENTDATE BETWEEN '2017-01-07' AND '2017-01-07'
AND NOT mintime <> maxtime
GROUP BY appointments.USERID,
users.LOCATIONID,
appointments.APPOINTMENTDATE
I get the error Mintime is not valid.
I am sure I need to hold this in a new sub select but not sure..
Cheers