id name xtdate number type
1 冰箱 2007-02-05 2 销售
2 电视 2007-02-05 2 销售
3 冰箱 2007-02-10 3 销售查询2007-02-06 日以后就没有销售记录的信息:
结果:
2 电视 2007-02-10 2 销售
1 冰箱 2007-02-05 2 销售
2 电视 2007-02-05 2 销售
3 冰箱 2007-02-10 3 销售查询2007-02-06 日以后就没有销售记录的信息:
结果:
2 电视 2007-02-10 2 销售
应该可以
Select A.* from table1 A
where A.id=(select count(*) from table1 where xtdate > 2007-02-06)-1)
where type = '销售'
and xtdate <= '2007-02-06'
and name not in (
select name from table_name where xtdate > '2007-02-06' and type = '销售'
)