27,579
社区成员
发帖
与我相关
我的任务
分享
select top 1 * from tb T
where (select sum(重量) from tb where 入仓号<=T.入仓号)>=100
order by 入仓号
select top 1 * from tb T
where (select sum(重量) from tb where 入仓号<T.入仓号)>=100
order by 入仓号
select 入仓号 ,重量 , 入仓时间
from
(
select a.* ,(select sum(重量)as 总重量 from tbl where a.入仓号<入仓号) as 前重量
,(select sum(重量)as 总重量 from tbl where a.入仓号<=入仓号) as 后重量
from tbl a
) b
where b.前重量<= 100 and b.后重量>100
select top 1 * from tb T
where (select sum(重量) from tb where 入仓时间<=T.入仓时间)>=100
order by 入仓时间