Reputation: 3793
This is an import from another place, so my data in BigQuery looks something like this:
order_id | owner_pk | owner_sk | other_properties | currency
I'd like to find if there are orders (order_id) coming from the same owner (PK+SK) that have different (distinct?) currency
values. I don't need the actual orders, true/false is ok.
Any help with querying for that is appreciated! :)
Upvotes: 0
Views: 159
Reputation: 1269493
You can use aggregation. I would return the currencies as well as the number:
select owner_pk, owner_sk,
array_agg(distinct currency) as currencies,
count(distinct currency) as num_currencies
from t
group by owner_pk, owner_sk;
Upvotes: 1