首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

求语句,该怎么解决

2012-01-15 
求语句时间---intA-----intB--11--12--24--....要搜索表中按时间倒叙排列后,对于每一个intA,他的最后一次

求语句
时间---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)

热点排行