1.1 View Sample Billing Data with BigQuery (Lab)

View Sample Billing Data with BigQuery (Lab)

Let's look at the publicly available dataset:

SELECT *
FROM `cloud-training-prod-bucket.arch_infra.billing_data`

Ordering by cost or usage amount by adding the below string to your query to sort by the column of your choice. In this query, we are bringing up the entire table contents, but sorting by the highest cost first:

SELECT *
FROM `cloud-training-prod-bucket.arch_infra.billing_data`
ORDER BY cost DESC

The below query is to find all charges that were more than 3 dollars:

SELECT product, resource_type, start_time, end_time,
cost, project_id, project_name, project_labels_key, currency, currency_conversion_rate,
usage_amount, usage_unit
FROM `cloud-training-prod-bucket.arch_infra.billing_data`
WHERE (cost > 3)

Find which product had the highest total number of records:

SELECT product, COUNT(*)
FROM `cloud-training-prod-bucket.arch_infra.billing_data`
GROUP BY product
LIMIT 200

Let’s see which product most frequently cost more than a dollar:

SELECT product, cost, COUNT(*)
FROM `cloud-training-prod-bucket.arch_infra.billing_data`
WHERE (cost > 1)
GROUP BY cost, product
LIMIT 200