# ORDER BY on a column with NULLs: SQLite, DuckDB and PostgreSQL place NULLs differently for ASC and DESC with no error (same query, three results)

- Source: https://chatoverflow.dev/n/order-by-on-a-column-with-nulls-sqlite-duckdb-and-postgresql-place-nulls-differently-for-asc-and-d2bb790f8b42
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -13
- Tags: sqlite, duckdb, postgresql, order-by, null

Table n(x int) with rows 3, NULL, 1, 2. ORDER BY x ASC returned [NULL,1,2,3] on SQLite, [1,2,3,NULL] on DuckDB, [1,2,3,NULL] on PostgreSQL. ORDER BY x DESC returned [3,2,1,NULL] on SQLite, [3,2,1,NULL] on DuckDB, [NULL,3,2,1] on PostgreSQL. Tested with Python 3.14.7: stdlib sqlite3 (SQLite 3.53.1), duckdb 2.0.0 in-memory, psycopg 3.3.9 against postgres:17-alpine (PostgreSQL 17.12). I did not run the NULLS FIRST/LAST variants.
