sum(case when datepart(month,统计日期)=1 then 支付金额 else 0 end) as '1月',
sum(case when datepart(month,统计日期)=2 then 支付金额 else 0 end) as '2月',
sum(case when datepart(month,统计日期)=3 then 支付金额 else 0 end) as '3月',
sum(case when datepart(month,统计日期)=4 then 支付金额 else 0 end) as '4月',
sum(case when datepart(month,统计日期)=5 then 支付金额 else 0 end) as '5月',
sum(case when datepart(month,统计日期)=6 then 支付金额 else 0 end) as '6月',
sum(case when datepart(month,统计日期)=7 then 支付金额 else 0 end) as '7月',
sum(case when datepart(month,统计日期)=8 then 支付金额 else 0 end) as '8月',
sum(case when datepart(month,统计日期)=9 then 支付金额 else 0 end) as '9月',
sum(case when datepart(month,统计日期)=10 then 支付金额 else 0 end) as '10月',
sum(case when datepart(month,统计日期)=11 then 支付金额 else 0 end) as '11月',
sum(case when datepart(month,统计日期)=12 then 支付金额 else 0 end) as '12月'
where datepart(year,统计日期)='2023'
统计日期=convert(varchar(10),dateadd(month, 0,convert(varchar(10),DATEADD(year, DATEDIFF(year,0,getdate()), 0),120)),120)
union all select date=convert(varchar(10),dateadd(month,1,convert(varchar(10),DATEADD(year, DATEDIFF(year,0,getdate()), 0),120)),120)
union all select date=convert(varchar(10),dateadd(month,2,convert(varchar(10),DATEADD(year, DATEDIFF(year,0,getdate()), 0),120)),120)
union all select date=convert(varchar(10),dateadd(month,3,convert(varchar(10),DATEADD(year, DATEDIFF(year,0,getdate()), 0),120)),120)
union all select date=convert(varchar(10),dateadd(month,4,convert(varchar(10),DATEADD(year, DATEDIFF(year,0,getdate()), 0),120)),120)
union all select date=convert(varchar(10),dateadd(month,5,convert(varchar(10),DATEADD(year, DATEDIFF(year,0,getdate()), 0),120)),120)
union all select date=convert(varchar(10),dateadd(month,6,convert(varchar(10),DATEADD(year, DATEDIFF(year,0,getdate()), 0),120)),120)
union all select date=convert(varchar(10),dateadd(month,7,convert(varchar(10),DATEADD(year, DATEDIFF(year,0,getdate()), 0),120)),120)
union all select date=convert(varchar(10),dateadd(month,8,convert(varchar(10),DATEADD(year, DATEDIFF(year,0,getdate()), 0),120)),120)
union all select date=convert(varchar(10),dateadd(month,9,convert(varchar(10),DATEADD(year, DATEDIFF(year,0,getdate()), 0),120)),120)
union all select date=convert(varchar(10),dateadd(month,10,convert(varchar(10),DATEADD(year, DATEDIFF(year,0,getdate()), 0),120)),120)
union all select date=convert(varchar(10),dateadd(month,11,convert(varchar(10),DATEADD(year, DATEDIFF(year,0,getdate()), 0),120)),120)
select 统计日期=substring(convert(varchar(10),dateadd(month, 0,convert(varchar(10),DATEADD(year, DATEDIFF(year,0,getdate()), 0),120)),120),6,2)
union all select date=substring(convert(varchar(10),dateadd(month,1,convert(varchar(10),DATEADD(year, DATEDIFF(year,0,getdate()), 0),120)),120),6,2)
union all select date=substring(convert(varchar(10),dateadd(month,2,convert(varchar(10),DATEADD(year, DATEDIFF(year,0,getdate()), 0),120)),120),6,2)
union all select date=substring(convert(varchar(10),dateadd(month,3,convert(varchar(10),DATEADD(year, DATEDIFF(year,0,getdate()), 0),120)),120),6,2)
union all select date=substring(convert(varchar(10),dateadd(month,4,convert(varchar(10),DATEADD(year, DATEDIFF(year,0,getdate()), 0),120)),120),6,2)
union all select date=substring(convert(varchar(10),dateadd(month,5,convert(varchar(10),DATEADD(year, DATEDIFF(year,0,getdate()), 0),120)),120),6,2)
union all select date=substring(convert(varchar(10),dateadd(month,6,convert(varchar(10),DATEADD(year, DATEDIFF(year,0,getdate()), 0),120)),120),6,2)
union all select date=substring(convert(varchar(10),dateadd(month,7,convert(varchar(10),DATEADD(year, DATEDIFF(year,0,getdate()), 0),120)),120),6,2)
union all select date=substring(convert(varchar(10),dateadd(month,8,convert(varchar(10),DATEADD(year, DATEDIFF(year,0,getdate()), 0),120)),120),6,2)
union all select date=substring(convert(varchar(10),dateadd(month,9,convert(varchar(10),DATEADD(year, DATEDIFF(year,0,getdate()), 0),120)),120),6,2)
union all select date=substring(convert(varchar(10),dateadd(month,10,convert(varchar(10),DATEADD(year, DATEDIFF(year,0,getdate()), 0),120)),120),6,2)
union all select date=substring(convert(varchar(10),dateadd(month,11,convert(varchar(10),DATEADD(year, DATEDIFF(year,0,getdate()), 0),120)),120),6,2)
select id=ROW_NUMBER()OVER(ORDER BY t1.统计日期),
支付金额=sum(isnull(t2.支付金额,0))
select substring(convert(varchar,统计日期,120),6,2) as 统计日期,sum(支付金额) as 支付金额
where datepart(year,统计日期)='2023'
group by substring(convert(varchar,统计日期,120),6,2)
Select Year(统计日期) as 年份,Month(统计日期) as 月份,SUM(支付金额) as 支付金额
Group by Year(统计日期),Month(统计日期)
select year(统计日期) 年,month(统计日期) 月,
sum(支付金额) as 支付金额, sum(老买家支付金额) as 老买家支付金额,sum(支付件数) as 支付件数,
sum(直通车消耗) as 直通车消耗,sum(淘宝客佣金) as 淘宝客佣金,sum(钻石展位消耗) as 钻石展位消耗,
sum(PC端支付金额) as PC端支付金额,sum(无线端支付金额) as 无线端支付金额,
sum(PC端支付件数) as PC端支付件数,sum(无线端支付件数) as 无线端支付件数
group by year(统计日期),month(统计日期)
sum(支付金额) as 支付金额, sum(老买家支付金额) as 老买家支付金额,sum(支付件数) as 支付件数,
sum(直通车消耗) as 直通车消耗,sum(淘宝客佣金) as 淘宝客佣金,sum(钻石展位消耗) as 钻石展位消耗,
sum(PC端支付金额) as PC端支付金额,sum(无线端支付金额) as 无线端支付金额,
sum(PC端支付件数) as PC端支付件数,sum(无线端支付件数) as 无线端支付件数
SELECT a.统计日期, SUM(b.支付金额) as 支付金额 FROM
(SELECT 统计日期, SUM(支付金额) 支付金额 FROM TM店铺整体月指标 GROUP BY 统计日期) a
(SELECT 统计日期, SUM(支付金额) 支付金额 FROM TM店铺整体月指标 GROUP BY 统计日期) b
SELECT datepart(week, 统计日期) 周次, count(1) 销售天数,
sum(支付金额) as 支付金额, sum(老买家支付金额) as 老买家支付金额,sum(支付件数) as 支付件数,
sum(直通车消耗) as 直通车消耗,sum(淘宝客佣金) as 淘宝客佣金,sum(钻石展位消耗) as 钻石展位消耗,
sum(无线端支付金额) as 无线端支付金额,sum(PC端支付金额) as PC端支付金额,
sum(无线端支付件数) as 无线端支付件数, sum(PC端支付件数) as PC端支付件数
WHERE year(统计日期)=year(getdate())
GROUP BY datepart(week, 统计日期)
SELECT weekName 周次,count(1) 销售次数,
sum(支付金额) as 支付金额, sum(老买家支付金额) as 老买家支付金额,sum(支付件数) as 支付件数,
sum(直通车消耗) as 直通车消耗,sum(淘宝客佣金) as 淘宝客佣金,sum(钻石展位消耗) as 钻石展位消耗,
sum(无线端支付金额) as 无线端支付金额,sum(PC端支付金额) as PC端支付金额,
sum(无线端支付件数) as 无线端支付件数, sum(PC端支付件数) as PC端支付件数
SELECT cast(datepart(month,统计日期) as varchar(2)) + '月第'+ cast((datepart(week,统计日期) - datepart(week,convert(varchar(7),统计日期,120) + '-01') + 1) as varchar(2)) + '周'
weekName,支付金额,老买家支付金额,支付件数,直通车消耗,淘宝客佣金,钻石展位消耗,成功退款金额,无线端支付金额,PC端支付金额,无线端支付件数,PC端支付件数
WHERE year(统计日期)=year(getdate())
SELECT datepart(quarter, 统计日期) 季次, count(1) 销售次数,
sum(支付金额) as 支付金额, sum(老买家支付金额) as 老买家支付金额,sum(支付件数) as 支付件数,
sum(直通车消耗) as 直通车消耗,sum(淘宝客佣金) as 淘宝客佣金,sum(钻石展位消耗) as 钻石展位消耗,
sum(无线端支付金额) as 无线端支付金额,sum(PC端支付金额) as PC端支付金额,
sum(无线端支付件数) as 无线端支付件数, sum(PC端支付件数) as PC端支付件数
WHERE year(统计日期)=year(getdate())
GROUP BY datepart(quarter, 统计日期)