I'm writing some queries with Google BigQuery. I want to extract the JSON from an array. Somehow I can extract it. And @Mikhail Berlyant helped me here. But now the problem is in extracting JSON from the array without Duplicates.
Current Structure:
I what I tried:
WITH
cte AS (
SELECT
labels,
cost
FROM
BILLING.gcp_billing_export_v1)
SELECT
la,
cost
FROM
cte,
UNNEST(labels) AS la
See the cost box, the COST value is repeated twice, because we have 2 KEY, VALUE pairs in the array.
So while doing sum(cost)
with the group by la.key
then I'm getting the wrong value.
What Im looking for is,
Can anyone help me with this?