iid cid internalId itemid reversion createdDt 9299 9301 787653 757513 1 2009-06-16 13:15:01.654 9299 9301 100035687 757516 9 2009-11-11 09:57:53.933 9299 9301 100035678 757516 8 2009-11-11 09:48:30.453 9299 9301 100035651 757516 7 2009-11-11 09:29:05.057 9299 9301 100035633 757516 6 2009-11-11 08:57:39.020 9299 9301 100035632 757516 5 2009-11-11 08:56:38.613 9299 9301 100035631 757516 4 2009-11-11 08:53:50.453 我只需要 9299 9301 787653 757513 1 2009-06-16 13:15:01.653 NULL 9299 9301 100035687 757516 9 2009-11-11 09:57:53.933 C 这两条数据,也就是每个itemId 里 reversion最大的那个,有什么好办法吗 select t.* from @tab t where revers = (select max(revers) from @tab where itemiid = t.itemiid) order by t.itemiid select * from @tab a where not exists(select 1 from @tab where itemiid=a.itemiid and revers>a.revers)
取一类别的数据中最大的Number
最新推荐文章于 2022-02-25 21:57:21 发布