Skip site navigation (1) Skip section navigation (2)

changing null-values' sort order

From: <me(at)alternize(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: changing null-values' sort order
Date: 2005-11-20 00:31:57
Message-ID: 042801c5ed69$f15f70c0$0201a8c0@iwing (view raw or flat)
Thread:
Lists: pgsql-novice
hi list

coming from the MS-SQL Server world, we're migrating our applications slowly to pgsql 8.1. now we thumbled on a problem with different sort-order behaviours:

we got a table with dated records: 
table: votes (v_userid, v_date)

the v_date field can either be null or a date in the past. in mssql, sorting the table to list records in descending date-order

select v_date, v_userid from votes order by v_date desc

produces a list where first the records with dates are listed, and then the ones with nulls. in pgsql, the null-records are listed first before the date-records... how can this behaviour be changed?

mssql:
--------
2005-11-05  3
2005-11-01  4
2005-09-10  1
null  2
null  5

pgsql:
--------
null  2
null  5
2005-11-05  3
2005-11-01  4
2005-09-10  1

thanks in advance,
thomas

Responses

pgsql-novice by date

Next:From: Roland GieslerDate: 2005-11-20 06:22:08
Subject: Re: Large Objects in table
Previous:From: Marcus EngeneDate: 2005-11-19 22:45:42
Subject: Re: Application using PostgreSQL as a back end (experienced

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group