QuestenaPractice that shows what to review next
Question 8

In PostgreSQL 18, SELECT x FROM (VALUES (1),(NULL),(2)) AS v(x) ORDER BY x DESC; is run with no NULLS FIRST or NULLS LAST clause. Which value appears in the first row?

  1. The position of NULL is unspecified
  2. 2
  3. 1
  4. NULLCorrect answer

Explanation

The default is to sort as though nulls were larger than every non-null value, which makes NULLS FIRST the default for DESC and NULLS LAST the default for ASC. Answering 2 comes from carrying over the ASC behaviour, where the null does come last.

Continue with this test

Start practice
Question 8: In PostgreSQL 18, SELECT x FROM (VALUES (1),(NULL),(2)) AS… · SQL: NULL, Joins and Aggregates · Questena