求解楼主来点测试数据 看看 select a.* from t_hykbgjl a left join t_hykbgjl b on a.sJlbh=b.sJlbh+1 where b.nYe+a.nFse<>a.nYe
--sql 2000用子查询 SQL code: select m.* , n.* from ( select t.* , px = (select count(1) from t_hykbgjl where sKH = t.sKH and 记录号 < t.记录号) + 1 from t_hykbgjl t ) m, ( select t.* , px = (select count(1) from t_hykbgjl where sKH = t.sKH and 记录号 < t.记录号) + 1 from t_hykbgjl t ) n where m.sKH = n.sKH and n.px = m.px - 1 and m.nYe + n.nFse <> m.nYe