Skip to content

Instantly share code, notes, and snippets.

@kristinaconley
Last active December 17, 2015 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristinaconley/5667969 to your computer and use it in GitHub Desktop.
Save kristinaconley/5667969 to your computer and use it in GitHub Desktop.
SELECT
DISTINCT P.timeframe
,*
FROM @Projected P
INNER JOIN (
SELECT
s1.timeframe
,RunningTotal = (SELECT SUM(s2.Contacts)
FROM @Projected s2
WHERE s2.timeframe <= s1.timeframe)
FROM @Projected s1
)P2 ON P.timeframe = P2.timeframe AND P.Contacts IS NOT null
ORDER BY 1
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment