Backend Database PostgreSQL Ruby On Rails

Unexpected behavior of PostgreSql

When you sort data in PostgreSql, using `order by` clause, its behavior is special.

When there are null values in the column data, `order by column DESC` puts null values first.

For example, there are only 4 rows with values ‘1’, ‘2’, ‘3’, null for column ‘A’, if developer uses `order by A DESC`, row order is null, ‘1’, ‘2’, 3′, which is really unexpected!

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *