NULL sorting in BigQuery

David542

Is there a way to specify the following in the order by statement in BigQuery, or do the equivalent?

SELECT * FROM books
ORDER BY books ASC (nulls first)

or:

SELECT * FROM books
ORDER BY books ASC (nulls last)

This would need to be within the item itself, not adding on a second item such as:

ORDER BY books IS NULL ASC, books ASC

Ideally, I'd like to apply it across an entire table (all queries for it) or something like that.

Here is this feature in Postgres: https://stackoverflow.com/a/9511492/651174

Yun Zhang

Since May 1st 2020, NULLS FIRST and NULLS LAST feature is available

https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#order_by_clause

Your example can be expressed as

SELECT * FROM books
ORDER BY books ASC NULLS FIRST

and

SELECT * FROM books
ORDER BY books ASC NULLS LAST

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related