# Controlling ordering of NULL values in the ORDER BY clause


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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717623214381/ff7df3d5-e17f-419b-a60c-129a17c87aa2.jpeg align="center")

*Found it useful? Subscribe to my Analytics newsletter at* [*notjustsql.com*](https://notjustsql.com)*.*

---

*Enjoyed this? Here are some related articles you might find useful:*

- [A couple of fun things about NULL in SQL](https://datawise.dev/a-couple-of-fun-things-about-null-in-sql)
- [Not all NULLS are the same](https://datawise.dev/not-all-nulls-are-the-same)
- [COALESCE vs IFNULL vs NULLIF in BigQuery](https://datawise.dev/coalesce-vs-ifnull-vs-nullif-in-bigquery)
- [Null-safe comparison: IS DISTINCT/NOT DISTINCT FROM](https://datawise.dev/null-safe-comparison-is-distinctnot-distinct-from)

