select * from (
select a.id,a.cntid,a.subject,a.previewfile,a.producetime,b.name,
row_number() over (patition by cntid order by A.producetime desc) rank1
from A,B where a.status=1 and b.status=1 and a.id=b.id
)
where rank1<=5

解决方案 »

  1.   

    select a.id,a.cntid,a.subject,a.previewfile,a.producetime,b.name from a,b where A.cntid=B.id and a.status!='1'
    union all
    select * from (select a.id,a.cntid,a.subject,a.previewfile,a.producetime,b.name from a,b where A.cntid=B.id and a.status='1' and b.status='1' order by A.producetime desc) where rownum<6