Skip to content

Instantly share code, notes, and snippets.

@aaronpdennis
Last active January 21, 2016 22:13
Show Gist options
  • Save aaronpdennis/da5686a2276a034ed0d2 to your computer and use it in GitHub Desktop.
Save aaronpdennis/da5686a2276a034ed0d2 to your computer and use it in GitHub Desktop.
SELECT
the_geom_webmercator,
precinct_number,
cartodb_id,
democratic_obama_biden, -- 1st Candidate
republican_mccain_palin, -- 2nd Cadidate
CAST ((democratic_obama_biden - -- change to 1st candidate
republican_mccain_palin ) AS float) -- change to 2nd candidate
/
CAST ((democratic_obama_biden + -- change to 1st candidate
republican_mccain_palin ) AS float) -- change to 2nd candidate
* 100
AS margin
FROM obama_vs_mccain_2008 -- TABLE NAME
WHERE
precinct_number IS NOT null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment