SQL Basics

SQL Basics

PURPOSE

  • A list of SQL queries that any developer worth his salt must know (or at least understand)

Listing everything inside a table

SELECT * FROM table;
  • Note that this can be a very costly query when running on a service like bigquery
  • It is adviced to always use a date column on which the table is partioned to reduce the query cost
SELECT *
FROM table
WHERE PARTITION_TIME >= "2021-04-23";

Accepted Logical Operators in SQL/BigQuery

Column Type Operator Description
DATE >= Greater than or equal to specified date
BOOL IS Check if a value is true, false or null
BOOL NOT Negation
SELECT *
FROM table
WHERE PARTITION_TIME >= "2021-04-23"
AND
is_vtx_enabled IS NOT NULL;

Steps to query a table in BigQuery

See this document


Tagged in sqlbigquery