Created
July 23, 2019 23:48
-
-
Save QuantVI/1aa51ba19f2bc2f962b45c601e67aac7 to your computer and use it in GitHub Desktop.
HP Vertica SQL query using the OVER window function combined with a relative date range.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
day, | |
clicks, | |
SUM(clicks) OVER (order by day range between '7 days' preceding and current row) accumulated_clicks | |
FROM | |
datamart.fact_network_stats_daily | |
WHERE | |
network_id = 72 | |
AND affiliate_country_code = 'FR' | |
AND banner_currency_id = 1 | |
AND YEAR(day) = 2014 | |
ORDER BY | |
day | |
LIMIT 200 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment