--测试--测试数据 create table 表1(id varchar(10),quantity decimal(10,2)) insert 表1 select '001',10.50 union all select '002',11.30 union all select '003',12.00 union all select '004', 5.50 union all select '005', 3.50 go--查询 select * from 表1 a where isnull((select sum(quantity) from 表1 where id>a.id),0)<20 order by id desc go--删除测试 drop table 表1/*--测试结果id quantity ---------- ------------ 005 3.50 004 5.50 003 12.00(所影响的行数为 3 行) --*/
create table 表1(id varchar(10),quantity decimal(10,2))
insert 表1 select '001',10.50
union all select '002',11.30
union all select '003',12.00
union all select '004', 5.50
union all select '005', 3.50
go--查询
select * from 表1 a
where isnull((select sum(quantity) from 表1 where id>a.id),0)<20
order by id desc
go--删除测试
drop table 表1/*--测试结果id quantity
---------- ------------
005 3.50
004 5.50
003 12.00(所影响的行数为 3 行)
--*/