1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| USE BarForce
With src as
(
SELECT CONVERT(date, FirstInProductionDate) AS Datum
, COUNT(CONVERT(date, FirstInProductionDate)) As FirstInProductionDate
, 1 as src
FROM SlitteApp
WHERE FirstInProductionDate IS NOT NULL
AND CONVERT(date, FirstInProductionDate) >= DATEADD("D", -30, getdate())
GROUP BY CONVERT(date, FirstInProductionDate)
UNION ALL
SELECT CONVERT(date, FirstDownloadBtnIOSDate) AS Datum1
, COUNT(CONVERT(date, FirstDownloadBtnIOSDate)) AS FirstDownloadBtnIOSDate
, 2
FROM SlitteApp
WHERE FirstDownloadBtnIOSDate IS NOT NULL
AND CONVERT(date, FirstInProductionDate) >= DATEADD("D", -30, getdate())
GROUP BY CONVERT(date, FirstDownloadBtnIOSDate)
UNION ALL
SELECT CONVERT(date, FirstDownloadBtnAndroidDate) AS Datum2
, COUNT(CONVERT(date, FirstDownloadBtnAndroidDate)) AS FirstDownloadBtnAndroidDate
, 3
FROM SlitteApp
WHERE FirstDownloadBtnAndroidDate IS NOT NULL
AND CONVERT(date, FirstInProductionDate) >= DATEADD("D", -30, getdate())
GROUP BY CONVERT(date, FirstDownloadBtnAndroidDate)
)
select Datum
, sum(case src when 1 then FirstInProductionDate else 0 end) as FirstInProductionDate
, sum(case src when 2 then FirstDownloadBtnIOSDate else 0 end) as FirstDownloadBtnIOSDate
, sum(case src when 3 then FirstDownloadBtnAndroidDate else 0 end) as FirstDownloadBtnAndroidDate
from src
group by Datum
order by Datum asc; |
Partager