Skip to content

Instantly share code, notes, and snippets.

@chadwhitacre
Created December 7, 2012 21:47
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 chadwhitacre/4236798 to your computer and use it in GitHub Desktop.
Save chadwhitacre/4236798 to your computer and use it in GitHub Desktop.
SETUP_NEW_TIPS_TO = """
INSERT INTO tips (ctime, tipper, tippee, amount)
SELECT DISTINCT ON (tipper)
min(ctime), tipper, %s AS tippee, sum(amount)
FROM tips
WHERE tippee=%s OR tippee=%s
GROUP BY tipper, mtime
ORDER BY tipper, mtime DESC;
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment