with d as (
SELECT
user_email,
query,
SUM(total_bytes_billed) AS bytes_billed
FROM
`region-us`.INFORMATION_SCHEMA.JOBS
WHERE
job_type = 'QUERY'
-- AND statement_type != 'SCRIPT'
and
date(creation_time) >= PARSE_DATE('%Y%m%d', '20230718')
and date(creation_time) <= PARSE_DATE('%Y%m%d', '20230718')
GROUP BY
user_email, query
)
select
user_email,
query,
bytes_billed / 1000000000000 tb,
bytes_billed / 1000000000000 * 5 as cost_usd
from d
order by 2 desc
with d as (
SELECT
user_email,
query,
SUM(total_bytes_billed) AS bytes_billed,
count(*) query_cnt
FROM
`region-us`.INFORMATION_SCHEMA.JOBS
WHERE
job_type = 'QUERY'
-- AND statement_type != 'SCRIPT'
and
date(creation_time) >= PARSE_DATE('%Y%m%d', '20230718')
and date(creation_time) <= PARSE_DATE('%Y%m%d', '20230718')
GROUP BY
user_email, query
)
select
user_email,
query,
query_cnt,
bytes_billed / 1000000000000 tb,
bytes_billed / 1000000000000 * 5 as cost_usd
from d
where user_email like '%sise%'
order by 5 desc