Skip to content

Instantly share code, notes, and snippets.

@antstanley
Created November 21, 2024 12:26
Show Gist options
  • Save antstanley/a66a9004c3359df6f499097fd0dc34a5 to your computer and use it in GitHub Desktop.
Save antstanley/a66a9004c3359df6f499097fd0dc34a5 to your computer and use it in GitHub Desktop.
SQL Statement to Compare Average Hours worked per country across 1990s, 2000's, and 2010's
SELECT "2000s".Entity, "1990s".AvgHours as "1990 - 1999", "2000s".AvgHours as "2000 - 2009", "2010s".AvgHours as "2010 - 2019" FROM (SELECT Entity, AVG("Average annual working hours per worker") AS AvgHours FROM read_csv_auto('https://ourworldindata.org/grapher/annual-working-hours-per-worker.csv?v=1&csvType=full&useColumnShortNames=true') WHERE Year BETWEEN 2010 AND 2019 GROUP BY "Entity") AS "2010s" INNER JOIN (SELECT Entity, AVG("Average annual working hours per worker") AS AvgHours FROM read_csv_auto('https://ourworldindata.org/grapher/annual-working-hours-per-worker.csv?v=1&csvType=full&useColumnShortNames=true') WHERE Year BETWEEN 2000 AND 2009 GROUP BY "Entity") AS "2000s" ON "2000s".Entity = "2010s".Entity INNER JOIN (SELECT Entity, AVG("Average annual working hours per worker") AS AvgHours FROM read_csv_auto('https://ourworldindata.org/grapher/annual-working-hours-per-worker.csv?v=1&csvType=full&useColumnShortNames=true') WHERE Year BETWEEN 1990 AND 1999 GROUP BY "Entity") AS "1990s" ON "1990s".Entity = "2000s".Entity ORDER BY "1990s".AvgHours DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment