日期:2014-05-17 浏览次数:20467 次
SELECT *
FROM tb a
WHERE EXISTS ( SELECT 1
FROM ( SELECT comunidb ,
MAX(columnida) columnida
FROM tb
GROUP BY comunidb
) b
WHERE a.columnida = b.columnida
AND a.comunidb = b.comunidb )
SELECT *
FROM (
SELECT *
,ROW_NUMBER() OVER (PARTITION BY IDB ORDER BY IDA) AS NUM
FROM TB
) T WHERE NUM=1