Thread: Bug with ORDER BY expression [ ASC | DESC ] ?

Bug with ORDER BY expression [ ASC | DESC ] ?

From
Christoph Haller
Date:
Hi, 
I am doing the following select in PostgreSQL 7.2.1 

select distinct on (o.sid,o.timepoint,o.lid,o.mid) o.sid,o.timepoint,o.lid,o.mid,o.value 
from onfvalue o, tempreftime t 
where o.sid=t.sid and o.timepoint=t.timepoint and o.lid=t.lid and o.mid=t.mid 
order by o.sid,o.timepoint,o.lid,o.mid,o.entrancetime desc;

but the result is coming in ascending order. 
There is no difference to 

select distinct on (o.sid,o.timepoint,o.lid,o.mid) o.sid,o.timepoint,o.lid,o.mid,o.value 
from onfvalue o, tempreftime t 
where o.sid=t.sid and o.timepoint=t.timepoint and o.lid=t.lid and o.mid=t.mid 
order by o.sid,o.timepoint,o.lid,o.mid,o.entrancetime asc; 

Is this a bug or am I missing something? 
Regards, Christoph 



Re: Bug with ORDER BY expression [ ASC | DESC ] ?

From
Tom Lane
Date:
Christoph Haller <ch@rodos.fzk.de> writes:
> select distinct on (o.sid,o.timepoint,o.lid,o.mid) o.sid,o.timepoint,o.lid,o.mid,o.value 
> from onfvalue o, tempreftime t 
> where o.sid=t.sid and o.timepoint=t.timepoint and o.lid=t.lid and o.mid=t.mid
> order by o.sid,o.timepoint,o.lid,o.mid,o.entrancetime desc;

> but the result is coming in ascending order. 

Perhaps you meant to say

order by o.sid desc, o.timepoint desc, o.lid desc, o.mid desc, o.entrancetime desc;
        regards, tom lane


Re: Bug with ORDER BY expression [ ASC | DESC ] ?

From
Christoph Haller
Date:
> 
> Christoph Haller <ch@rodos.fzk.de> writes:
> > select distinct on (o.sid,o.timepoint,o.lid,o.mid) o.sid,o.timepoint,o.lid,o.mid,o.value 
> > from onfvalue o, tempreftime t 
> > where o.sid=t.sid and o.timepoint=t.timepoint and o.lid=t.lid and o.mid=t.mid
> > order by o.sid,o.timepoint,o.lid,o.mid,o.entrancetime desc;
> 
> > but the result is coming in ascending order. 
> 
> Perhaps you meant to say
> 
> order by o.sid desc, o.timepoint desc, o.lid desc, o.mid desc, o.entrancetime desc;
> 
> 
Indeed. Thanks, Christoph