当前位置: 代码迷 >> Sql Server >> 求语句,该怎么解决
  详细解决方案

求语句,该怎么解决

热度:106   发布时间:2016-04-27 21:05:36.0
求语句
时间---intA-----intB
--             1                   1
--             1                   2
--             2                   4
--           ..                 ..
要搜索表中     按时间倒叙排列后,对于每一个intA,他的最后一次发生的B

结果以列表返回




------解决方案--------------------
select t.* from 表 t where not exists(select 1 from 表 where intA=t.intA and 时间> t.时间)
------解决方案--------------------
select * from 时间 a where not exists(select 1 from 时间 b where a.intA=b.intA and a.intB <b.intB)
  相关解决方案