Controlling ordering of NULL values in the ORDER BY clause


1 min read

Here's something I found out about the ORDER BY clause in BigQuery SQL the other day.

Check out the NULLS FIRST / NULLS LAST clauses. What do they do? They control how to treat NULL values when sorting.

While these are entirely optional, they're actually already happening behind the scenes even if you don't specify them.

๐Ÿ”น ORDER BY [column] ASC (which is the default) uses NULLS FIRST if unspecified
๐Ÿ”น ORDER BY [column] DESC uses NULLS LAST if unspecified

Found it useful? Subscribe to my Analytics newsletter at