DISTINCT

The legacy SQL does not support DISTINCT. The workaround is to use the group by statement, as shown in the following query. It outputs two columns: one is the column with distinct values and second is the count of those distinct values:

#legacySQL
SELECT payment_type, count(1)
FROM [bigquery-public-data:chicago_taxi_trips.taxi_trips]
GROUP BY payment_type
ORDER BY payment_type

Standard SQL supports the DISTINCT clause and it can be used as shown here. This query returns only one column as output:

#standardSQL
SELECT DISTINCT payment_type
FROM `bigquery-public-data.chicago_taxi_trips.taxi_trips`
ORDER BY payment_type
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.176.5