日期:2014-05-16 浏览次数:21021 次
with t (c_id, p_id, time) as (
select 'A', 'B', to_date('2012.03.12', 'yyyy.mm.dd') from dual
union all select 'A', 'B', to_date('2012.03.23', 'yyyy.mm.dd') from dual
union all select 'A', 'C', to_date('2012.04.12', 'yyyy.mm.dd') from dual
union all select 'A', 'C', to_date('2012.05.22', 'yyyy.mm.dd') from dual
)
select c_id, p_id, max(time) from t group by c_id, p_id;
select * from 你的表 t1 where t1.time=(select max(time) from 你的表 t2 where t1.c_id=t2.c_id and t1.p_id=t2.p_id);