Zalvena-Service/etc/clickhouse/queries/monthly_usage__v1.liquid
2025-02-19 16:44:17 -05:00

9 lines
No EOL
327 B
Text
Executable file

SELECT toYear(Date) as Year, toMonth(Date) as Month, Events
FROM (
SELECT period as Date,
countMerge(events) as Events
FROM monthly_usage_v1
WHERE app_id = '{{app_id}}'
GROUP BY period
ORDER BY period WITH FILL TO toStartOfMonth(now() + INTERVAL 1 MONTH) STEP toIntervalMonth(1)
) ORDER BY Year DESC, Month DESC