Skip to content

Instantly share code, notes, and snippets.

@markrittman
Created June 25, 2021 13:06
Show Gist options
  • Save markrittman/3459e734fdf1cf26ba7d5f8881797601 to your computer and use it in GitHub Desktop.
Save markrittman/3459e734fdf1cf26ba7d5f8881797601 to your computer and use it in GitHub Desktop.
SELECT
date_trunc(date(creation_time),MONTH) as billing_month,
user_email,
query,
count(distinct job_id) as query_runs,
sum(total_bytes_billed) as total_bytes_billed,
SUM(total_bytes_billed)/1e12*5 costInDollars
FROM
`region-eu`.INFORMATION_SCHEMA.JOBS_BY_PROJECT
WHERE
date_trunc(date(creation_time),MONTH) = '2021-05-01'
AND job_type = "QUERY"
GROUP BY
1,2,3
ORDER BY
6 DESC
LIMIT 40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment