Created
March 7, 2019 23:29
-
-
Save vinoaj/caa7544762f7578a6650db15c0c1f6c1 to your computer and use it in GitHub Desktop.
BigQuery SQL for GCP Billing Reports: Total Costs by Service for a specific Project
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
#standardSQL | |
SELECT | |
service.description | |
, ROUND(SUM(cost),2) AS total_cost | |
FROM `<project_id>.<dataset_id>.gcp_billing_export_v1_XXXXXX_XXXXXX_XXXXXX` | |
WHERE _PARTITIONTIME BETWEEN TIMESTAMP(DATE_SUB(CURRENT_DATE(), INTERVAL 365 DAY)) AND TIMESTAMP(CURRENT_DATE()) | |
AND project.id = '<project_name>' | |
GROUP BY service.description | |
ORDER BY total_cost DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment