Last active
October 12, 2019 09:29
-
-
Save neslinesli93/6ddf12f7841441ac912c746e1399916a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
WITH values as ( | |
SELECT | |
0 as value, | |
'' as label, | |
to_date('00000101','YYYYMMDD') as time | |
UNION ALL | |
SELECT | |
(close - open) / close as value, | |
to_char(time, 'Mon') || ' ' || to_char(time, 'YYYY') as label, | |
time | |
FROM "Tickers_Data" | |
WHERE extract(dow from time) = $1 AND ticker = $2 | |
) | |
SELECT | |
label, | |
sum(value) over (order by time asc rows between unbounded preceding and current row) as cumulative | |
FROM values |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment