Created
April 22, 2015 08:15
-
-
Save alex-groshev/06b1b0c55c2eb21e5a74 to your computer and use it in GitHub Desktop.
Daily Returns / SQL Server 2012+
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 | |
Date | |
,Value | |
,CAST(ROUND(100 * (Value / LAG(Value, 1, Value) OVER (ORDER BY Date) - 1), 2) AS NUMERIC(16, 2)) AS 'Return' | |
FROM Totals | |
ORDER BY Date; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment