Skip to content

Instantly share code, notes, and snippets.

@friscojosh
Created June 23, 2016 18:13
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 friscojosh/86f798e7fdaa38c76ec6f521d7f5ad75 to your computer and use it in GitHub Desktop.
Save friscojosh/86f798e7fdaa38c76ec6f521d7f5ad75 to your computer and use it in GitHub Desktop.
SQL to do complex year over year queries
SELECT a.player, a.fname, a.lname, a.year, a.top12
, b.year, b.top12
FROM
(SELECT __top12_weeks_WR.*
FROM __top12_weeks_WR)a
INNER JOIN
(SELECT __top12_weeks_WR.*
FROM __top12_weeks_WR)b
ON a.player = b.player
AND a.year = b.year - 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment