have a try:
没有实验环境:select id,test_date,track0,tracke1
from
(select a.id,a.test_date,a.track0,a.track1,
DENSE_RANK()
OVER (PARTITION BY a.id ORDER BY a.test_date desc) rank
from mat_dft_header a
where a.product='CALIBAN' and a.sw_version='V1.2.0' and a.tape_id<>'FUJIG1-4'
) b
where rank<=2
没有实验环境:select id,test_date,track0,tracke1
from
(select a.id,a.test_date,a.track0,a.track1,
DENSE_RANK()
OVER (PARTITION BY a.id ORDER BY a.test_date desc) rank
from mat_dft_header a
where a.product='CALIBAN' and a.sw_version='V1.2.0' and a.tape_id<>'FUJIG1-4'
) b
where rank<=2
from
(select a.id,a.test_date,a.track0,a.track1,
(DENSE_RANK()
OVER (PARTITION BY a.id ORDER BY a.test_date desc)) rank1
from mat_dft_header a
where a.product='CALIBAN' and a.sw_version='V1.2.0' and a.tape_id<>'FUJIG1-4'
) b
where rank1<=2
select * from
(
select * from
(select a.id mid,a.test_date,a.track0,a.track1 from mat_dft_header a
where a.product='CALIBAN' and a.sw_version='V1.2.0' and a.tape_id<>'FUJIG1-4'
order by a.id,a.test_date
) t
order by mid desc
)
where rownum<=2;