-- 方法1
SELECT *
FROM TB_GATEBUS G
WHERE (G.AUTOFAREGATENO, G.DEFINEDATE) IN
(SELECT GB.AUTOFAREGATENO, MAX(GB.DEFINEDATE)
FROM TB_GATEBUS GB
GROUP BY GB.AUTOFAREGATENO)
-- 方法2
SELECT *
FROM TB_GATEBUS G,
(SELECT GB.AUTOFAREGATENO, MAX(GB.DEFINEDATE) DEFINEDATE
FROM TB_GATEBUS GB
GROUP BY GB.AUTOFAREGATENO) H
WHERE G.AUTOFAREGATENO = H.AUTOFAREGATENO
AND G.DEFINEDATE = H.DEFINEDATE
时间: 2024-10-12 13:45:59