读书人

求语句,该怎么解决

发布时间: 2012-01-15 22:57:49 作者: rapoo

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

读书人网 >SQL Server

热点推荐