Last active
February 21, 2023 09:44
-
-
Save maratuska/008964a39225a06653dad6ca952a3c46 to your computer and use it in GitHub Desktop.
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
WITH charge_by_categories AS ( | |
SELECT | |
ca.category_no, | |
ca.category_desc, | |
ch.charge_amt | |
FROM charge ch | |
JOIN category ca | |
ON ch.category_no = ca.category_no | |
) | |
SELECT | |
cbc.category_desc, | |
SUM(cbc.charge_amt) summary_charge | |
FROM charge_by_categories cbc | |
GROUP BY cbc.category_no | |
ORDER BY summary_charge DESC | |
LIMIT 5; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment