Bigquery select distinct values

前端 未结 6 859
离开以前
离开以前 2021-01-11 10:03

How to select distinct values in Google Bigquery?

Query:

SELECT DISTINCT cc_info
FROM user
WHERE date = ?

Thanks!

6条回答
  •  醉梦人生
    2021-01-11 10:43

    SELECT COUNT(DISTINCT cc_info)
    FROM user
    WHERE date = ?
    

    is NOT the right query, because DISTINCT is a statistical approximation and is not guaranteed to be exact. See https://cloud.google.com/bigquery/docs/reference/legacy-sql#countdistinct

    So better approach is

    select EXACT_COUNT_DISTINCT(cc_info) from user where date = ?
    

提交回复
热议问题