Skip to content

Instantly share code, notes, and snippets.

@Mr--John-Doe
Last active January 17, 2022 08:29
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 Mr--John-Doe/13edd6924c2532ee13ce483911a994a8 to your computer and use it in GitHub Desktop.
Save Mr--John-Doe/13edd6924c2532ee13ce483911a994a8 to your computer and use it in GitHub Desktop.
WindowFunctions-QueryB-WithRoundingIssues
SELECT day AS day_of_week
, COUNT(*) AS dow_accidents
, SUM(dow_accidents) OVER (PARTITION BY 0) AS total_accidents
, ROUND(dow_accidents / total_accidents, 4) AS dow_accidents_percent
FROM temp.CAMBRIDGESHIRE_ACCIDENTS
WHERE accident_ts BETWEEN '2017-01-01'::date AND '2017-01-31'::date
GROUP BY 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment