标签:else let har customers convert mount mod creat number
select Date,ISNULL(NewFans,0) NewFans,ISNULL(NewMembers,0) NewMembers, ISNULL(NewBinds,0) NewBinds,
ISNULL(Recharges,0) Recharges,
ISNULL(Consume,0) Consume,ISNULL(PayCounts,0) PayCounts,ISNULL(PayCustomers,0) PayCustomers,
ISNULL(Amount,0) Amount,ISNULL(UnitPrice,0) UnitPrice
from (
SELECT substring(convert(char(32),DATEADD(dd,number,‘2019-08-22‘),120),1,10) AS Date
,type FROM master..spt_values
WHERE type = ‘p‘ AND DATEDIFF(DD,DATEADD(DD,number,‘2019-08-22‘),‘2019-08-29‘)>=0
) a
left join (
select convert(char(32),CreateDate,23) as st,
SUM(CASE WHEN(ModuleType = 1) THEN NumResult ELSE 0 END) NewFans ,
SUM(CASE WHEN(ModuleType = 2) THEN NumResult ELSE 0 END) NewMembers,
SUM(CASE WHEN(ModuleType = 3) THEN NumResult ELSE 0 END) NewBinds,
SUM(CASE WHEN(ModuleType = 4) THEN NumResult ELSE 0 END) Recharges,
SUM(CASE WHEN(ModuleType = 5) THEN NumResult ELSE 0 END) Consume,
SUM(CASE WHEN(ModuleType = 6) THEN NumResult ELSE 0 END) PayCounts,
SUM(CASE WHEN(ModuleType = 7) THEN NumResult ELSE 0 END) PayCustomers,
SUM(CASE WHEN(ModuleType = 8) THEN NumResult ELSE 0 END) Amount,
SUM(CASE WHEN(ModuleType = 9) THEN NumResult ELSE 0 END) UnitPrice
from MallStatistics_P39 where CustId = 848839
and CreateDate between ‘2019-08-22‘ and ‘2019-08-29‘ --and BranchNo =‘‘
group by convert(char(32),CreateDate,23),CustId
) b
on b.st=a.Date order by a.Date
标签:else let har customers convert mount mod creat number
原文地址:https://www.cnblogs.com/opts/p/11429800.html