Bigquery select distinct values

前端 未结 6 961
离开以前
离开以前 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:39

    For all who have come to find the DISTINCT method in BigQuery, and who needs to use unique field feature for tables having large columns, using GROUP BY as mentioned by tning won't be possible.

    As of 2020, BigQuery has DISTINCT modifier. You need to wrap your query as:

    SELECT DISTINCT usr.cc_info
    FROM (
      SELECT *
      FROM user
      WHERE date = ?
    ) usr
    

    This could be very handy for people shifting from other SQL products.

提交回复
热议问题