qq_24420983 于 2016.03.17 14:38 提问

declare @Jishu int=25
declare @Bianliang numeric=0
while @Jishu<=65
begin
SELECT @Bianliang=sum(dbo.LKG_CardsTong.TicketRemainCount) FROM dbo.LKG_CardsTong INNER JOIN
dbo.LKG_CardsTongKinds ON dbo.LKG_CardsTong.CardTKind = dbo.LKG_CardsTongKinds.CardTKindID

where ((dbo.LKG_CardsTong.CardTNumber like'5%')or(dbo.LKG_CardsTong.CardTNumber like'7%')or
(dbo.LKG_CardsTong.CardTNumber like'85%')) AND dbo.LKG_CardsTongKinds.CardTKindValue=@Jishu and dbo.LKG_CardsTong.CardTStatus =1 AND dbo.LKG_CardsTong.TicketRemainCount IS NOT NULL
set @Bianliang = case when @Bianliang is null then 0 else @Bianliang end
if @Jishu=25
begin
set @Jiesuan25= @Jishu*@Bianliang
end
else if @Jishu=30
begin
set @Jiesuan30= @Jishu*@Bianliang
end
else if @Jishu=35
begin
set @Jiesuan35= @Jishu*@Bianliang
end
else if @Jishu=40
begin
set @Jiesuan40= @Jishu*@Bianliang
end
else if @Jishu=45
begin
set @Jiesuan45= @Jishu*@Bianliang
end
else if @Jishu=50
begin
set @Jiesuan50= @Jishu*@Bianliang
end
else if @Jishu=55
begin
set @Jiesuan55= @Jishu*@Bianliang
end
else if @Jishu=60
begin
set @Jiesuan60= @Jishu*@Bianliang
end
else
begin
set @Jiesuan65= @Jishu*@Bianliang

end
set @Jishu+=5
end

2个回答

qq_24420983   2016.03.17 14:39

qq_24420983   2016.03.17 14:40