48
loading...
This website collects cookies to deliver better user experience
LIMIT
clause !)-- this will give you a random 10% of a table data
SELECT * FROM dataset.my_table TABLESAMPLE SYSTEM (10 PERCENT)
CREATE OR REPLACE TABLE FUNCTION mydataset.names_by_year(y INT64)
AS
SELECT year, name, SUM(number) AS total
FROM `bigquery-public-data.usa_names.usa_1910_current`
WHERE year = y
GROUP BY year, name
-- use your table function in an other query, just like a view
SELECT * FROM mydataset.names_by_year(1950)
ORDER BY total DESC
LIMIT 5
STRING
, BYTES
, NUMERIC
and BIGNUMERIC
. Want to raise an error if the text value in a certain column is larger than 10 characters ? Type your column as STRING(10)
SELECT item
FROM Produce
WHERE Produce.category = 'vegetable'
QUALIFY RANK() OVER (PARTITION BY category ORDER BY purchases DESC) <= 3