我正在使用多個select語句來驅動結果,但是我有2個select語句,它返回約會的最短時間和最大約會時間。但是,在最小和最大值相同的情況下,我想從我的where子句中刪除。在你的Where子句中使用Select Min和MAx
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
我得到錯誤Mintime無效。
我相信,我需要一個新的子選擇,但不知道舉辦這個..
乾杯
左對齊SQL是太難讀... – jarlh