字段1(sz) 字段2(rq) 字段3(id) 字段4(class)
0 20051230 1 c1
12 20051231 2 c1
0 20060101 3 c1
2 20060101 4 c2第3条记录符合最大日期的sz值为0,且同一class的上一天的sz值不为零,c1就是符号记录的一条记录
0 20051230 1 c1
12 20051231 2 c1
0 20060101 3 c1
2 20060101 4 c2第3条记录符合最大日期的sz值为0,且同一class的上一天的sz值不为零,c1就是符号记录的一条记录
(select max(rq) as maxrq, class From TempTable group by class) b
Where a.class = b.class and a.rq = b.maxrq) m Where
m.class not in (select class from TempTable where class = m.class and rq = m.rq - 1 and sz = 0) and m.sz = 0