I am using Postgresql version 9.1.9:
"PostgreSQL 9.1.9 on armv7l-unknown-linux-gnueabihf,
compiled by gcc (Debian 4.6.3-14+rpi1) 4.6.3, 32-bit"
select "A", dense_rank() over (order by "A" desc) from public."Test"
Note: The SQL standard defines a RESPECT NULLS or IGNORE NULLS option
for lead, lag, first_value, last_value, and nth_value. This is not
implemented in PostgreSQL: the behavior is always the same as the
standard's default, namely RESPECT NULLS. Likewise, the standard's
FROM FIRST or FROM LAST option for nth_value is not implemented: only
the default FROM FIRST behavior is supported. (You can achieve the
result of FROM LAST by reversing the ORDER BY ordering.)
NULLS LAST clause to modify how
NULL values are sorted. Does exactly what you asked for:
SELECT "A", dense_rank() OVER (ORDER BY "A" DESC NULLS LAST) FROM public."Test"
Not just for window functions, for
ORDER BY anywhere.
Postgres does the right thing out of the box. Since
NULL sorts last in ascending order, it should come first by default when the order is inverted.