Created
September 25, 2016 02:27
-
-
Save alexpetralia/d758eae248488052b8c75fd67612bd94 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
cnxn = engine.connect() | |
r = cnxn.execute(""" | |
WITH igm AS ( | |
SELECT economist_name, institution, AVG(confidence) AS avg_conf | |
FROM igmchicago | |
GROUP BY economist_name, institution | |
) | |
SELECT * FROM igm i | |
WHERE avg_conf > | |
(SELECT AVG(avg_conf) FROM igm g WHERE i.institution = g.institution) | |
ORDER BY institution, avg_conf | |
""") | |
r.fetchall() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment