Last active
January 14, 2022 17:56
-
-
Save Mr--John-Doe/4cdc80c02da1e492a5dd36e3f8c41593 to your computer and use it in GitHub Desktop.
WindowFunctions-QueryA-NoWindowFunc
This file contains 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
SELECT row_level.DATE AS date | |
, row_level.police_ref AS police_ref | |
, row_level.casualties AS casualties | |
, agg.day_total_casualties AS day_total_casualties | |
, row_level.casualties / agg.day_total_casualties AS casualties_percent_of_day | |
FROM temp.CAMBRIDGESHIRE_ACCIDENTS row_level | |
INNER JOIN (SELECT date, SUM(casualties) AS day_total_casualties | |
FROM temp.CAMBRIDGESHIRE_ACCIDENTS | |
GROUP BY DATE) agg | |
ON row_level.date = agg.date |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment