How to select distinct values in Google Bigquery?
Query:
SELECT DISTINCT cc_info
FROM user
WHERE date = ?
Thanks!
A SELECT DISTINCT statement discards duplicate rows and returns only the remaining rows. SELECT DISTINCT cannot return columns of the following types: STRUCT. ARRAY.
The WITH clause contains one or more common table expressions (CTEs). Each CTE binds the results of a subquery to a table name, which can be used elsewhere in the same query expression. BigQuery does not materialize the results of non-recursive CTEs within the WITH clause.
SELECT cc_info
FROM user
WHERE date = ?
GROUP BY cc_info
Simply use group by,
SELECT cc_info
FROM user
WHERE date = ?
GROUP BY cc_info
If you want to COUNT over DISTINCT values you can use,
SELECT COUNT(DISTINCT cc_info)
FROM user
WHERE date = ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With