挑选分组中top1

select * from
(

select *, ROW_NUMBER() over(partition by accountid order by opentime DESC) as rowNum
from ep_productopenhistory
WHERE accountid IN
(
SELECT accountid FROM dbo.ep_accountno
WHERE name IN
(
'1334760',
'1334761',
'1334762',
'1334763',
'1334764',
'1334765',
'1334766',
'1334767'
)
)

) ranked
where ranked.rowNum =1
order by ranked.accountid, ranked.opentime desc

上一篇:关于arraylist.remove的一些小问题。


下一篇:UCOS-2 消息邮箱与队列