BigQuery is very similar to SQL and is easy so here is my cheatsheet.
- SELECT:
SELECT * FROM table;
SELECT ... FROM ... WHERE condition
SELECT ... FROM ... WHERE condition GROUP BY field;
SELECT ... FROM ... ORDER BY field1, field2 ASC;
SELECT ... FROM ... WHERE condition ORDER BY field1, field2 DESC;
SELECT ... FROM ... LIMIT 10;
SELECT DISTINCT field1 FROM ... table;
SELECT DISTINCT field1, field2 FROM ... table;
- CONDITIONS:
field1 = value1
t1.field = t2.field
field1 <> value1
field1 LIKE 'value _ %'
field1 IS NULL
field1 IS NOT NULL
field1 IS IN (value1, value2)
field1 IS NOT IN (value1, value2)
condition1 AND condition2
condition1 OR condition2
- AGGREGATION FUNCTIONS:
MAX()
MIN()
AVG()
CONCAT()
STRING_AGG()
- COMMON TABLE EXPRESSIONS (CTE):
WITH CTE_table_name AS ( query );
- JOINS:
Silverboy
Top comments (0)