我需要每分鐘檢查用戶的最小值和最大值。我試圖找到這樣做,但我失敗了。SQL服務器的最小值和最大值
SELECT CONVERT(VARCHAR(10), checktime, 120),
CONVERT(VARCHAR(8), checktime, 108) Time,
userid,
Max(checktime) CheckTimeEvent,
checktype
FROM checkinout,
workdateview
WHERE CONVERT(VARCHAR(10), checktime, 120) = workdateview.workdate
AND userid = 2
AND checktype = 'O'
GROUP BY CONVERT(VARCHAR(10), checktime, 120),
CONVERT(VARCHAR(8), checktime, 108),
userid,
checktype
UNION
SELECT CONVERT(VARCHAR(10), checktime, 120),
CONVERT(VARCHAR(8), checktime, 108) Time,
userid,
Min(checktime) CheckTimeEvent,
checktype
FROM checkinout,
workdateview
WHERE CONVERT(VARCHAR(10), checktime, 120) = workdateview.workdate
AND userid = 2
AND checktype = 'I'
GROUP BY CONVERT(VARCHAR(10), checktime, 120),
CONVERT(VARCHAR(8), checktime, 108),
userid,
checktype
什麼** datatype **是那些列?!?!?! –