Search Postgresql Archives

Re: Stable sort?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



redhog wrote:
> Is sorting in PostgreSQL stable over subqueries, that is, is
> 
> select * from (select * from A order by x) as B order by y;
> 
> equivalent with
> 
> select * from A order by y, x;

Seems as easy to try as to guess.

If I did this query right, it seems not.

select * from (select random()>0.5 as a, random()>0.5 as b from generate_series(1,10) order by a) as x order by b;
 a | b
---+---
 f | t
 f | f
 f | f
 f | f
 f | t
 f | f
 t | t
 t | t
 t | t
 t | f
(10 rows)

OTOH, HEY, why isn't that result ordered by 'b' instead of by 'a' (or am I misreading my query or the results)?


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux