SQL Docs
SQL referenceCore SQLFunctionsJoinsWindow functions

Core SQL

Build your SQL foundation with logic, ordering, and null semantics that matter in production.

Foundations that trip people up

These pages cover the semantics most likely to cause bad production queries:

Keep this checklist close

  • NULL is not equal to anything
  • ORDER BY without a tiebreaker is not stable
  • GROUP BY changes the grain of the result
  • a query is only safe when the business rule is explicit

Example

SELECT
  customer_id,
  COALESCE(MAX(order_date), 'never') AS last_order_date,
  COUNT(*) AS orders
FROM orders
GROUP BY customer_id
ORDER BY customer_id;

On this page