求问问题所在。。。
declare @day date
set @day='2013-12-05'
declare @day_2 date
set @day_2='2013-12-08'
while(@day<@day_2)
begin
SELECT distinct opttype as 消耗项目,sum(ABS(lijinchange))as 消耗量,sum(count(distinct account))as 消费人数,SUM(sum(abs(lijinchange)))as 一天总消耗量,@day as 日期
FROM [mydb_extendsgamelog1].[dbo].[12_TS_PlayerLiJinChange_log]where lijinchange<0 and @day=(convert(date,logtime,105))and opttype not like 'auction buy item comm-%'group by opttype,@day
set @day=dateadd(dd,1,@day)
end
declare @day date
set @day='2013-12-05'
declare @day_2 date
set @day_2='2013-12-08'
while(@day<@day_2)
begin
SELECT distinct opttype as 消耗项目,
sum(ABS(lijinchange))as 消耗量,
sum(count(distinct account))as 消费人数,
SUM(sum(abs(lijinchange)))as 一天总消耗量,
@day as 日期
FROM [mydb_extendsgamelog1].[dbo].[12_TS_PlayerLiJinChange_log]
where lijinchange<0 and @day=(convert(date,logtime,105))and opttype not like 'auction buy item comm-%'
group by opttype,@day -->group by opttype,日期
set @day=dateadd(dd,1,@day)
end
declare @day date
declare @day1 date
set @day='2013-12-05'
set @day1 = @day
declare @day_2 date
set @day_2='2013-12-08'
while(@day<@day_2)
begin
SELECT distinct opttype as 消耗项目,
sum(ABS(lijinchange))as 消耗量,
count(distinct account)as 消费人数,
sum(abs(lijinchange))as 一天总消耗量,
@day as 日期
FROM [mydb_extendsgamelog1].[dbo].[12_TS_PlayerLiJinChange_log]
where lijinchange<0 and @day=(convert(date,logtime,105))
and opttype not like 'auction buy item comm-%'
group by opttype
set @day=dateadd(dd,1,@day)
end
SELECT distinct opttype as 消耗项目,
sum(ABS(lijinchange))as 消耗量,
count(distinct account)as 消费人数,
sum(abs(lijinchange))as 一天总消耗量,
@day as 日期 --合计
FROM [mydb_extendsgamelog1].[dbo].[12_TS_PlayerLiJinChange_log]
where lijinchange<0
and (convert(date,logtime,105))>=@day1
and (convert(date,logtime,105))<@day2
and opttype not like 'auction buy item comm-%'
group by opttype