I am using the BigQuery to get the cost details of GCP using the following query
SELECT
billing_account_id,
service.id as service_id,
service.description as service_des,
sku.id as sku_id,
sku.description as sku_des,
UNIX_MILLIS(MIN(usage_start_time)) as usage_start_time ,
UNIX_MILLIS(MAX(usage_end_time)) as usage_end_time,
location.location as location,
location.region as region,
location.country as country,
location.zone as zone,
UNIX_MILLIS(MAX(export_time)) as export_time,
invoice.month as invoice_mon,
currency,
currency_conversion_rate,
cost_type,
resource.name as resource_name,
resource.global_name as res_global_name,
SUM(usage.amount_in_pricing_units) as usage_amount_pricing_units,
usage.pricing_unit as pricing_unit,
labels,
system_labels,
cost,
cost_at_list,
transaction_type,
seller_name,
adjustment_info.id as adjustment_info_id,
adjustment_info.description as adjustment_des,
adjustment_info.type as adjustment_type,
adjustment_info.mode as adjustment_mode,
price.effective_price as effective_price,
price.pricing_unit_quantity as pricing_unit_quantity,
project.id as project_id,
project.number as project_number,
project.name as project_name,
credits.name as credit_name,
credits.amount as credit_amount,
credits.id as credit_id,
credits.type as credit_type,
credits.full_name as credit_full_name
FROM `XXXXXXX_1234467_XXXXX`
LEFT JOIN UNNEST(credits) as credits
WHERE (cost!=0 OR credits.amount!=0) AND
usage_start_time>=TIMESTAMP_MILLIS(1714262400000) AND
usage_end_time<=TIMESTAMP_MILLIS(1714348800000)
I have to do Grouping based on columns billing_account_id,service_id,sku_id,location,region,country,zone,invoice_mon,cost_type,
resource_name,adjustment_info_id,project_id,credit_id,credit_type,adjustment_type,transaction_type. Have to aggregate the usage_start_time and usage_end_time as day wise, currently
these are at hour wise.
I am passing day start and end time in criteria.
i tried to do but getting errors like “SELECT list expression references column labels which is neither grouped nor aggregated at [23:25]” and “Array cannot be grouped”