标签:sql
-- 方法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
本文出自 “Java乐园” 博客,请务必保留此出处http://hebinteng.blog.51cto.com/7967512/1956329
标签:sql
原文地址:http://hebinteng.blog.51cto.com/7967512/1956329