dbTalk Databases Forums  

Sorting, when values are equal....

comp.databases.postgresql.general comp.databases.postgresql.general


Discuss Sorting, when values are equal.... in the comp.databases.postgresql.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Net Virtual Mailing Lists
 
Posts: n/a

Default Sorting, when values are equal.... - 10-25-2004 , 06:45 AM






Hello,


If I do something like:

SELECT * FROM sometable ORDER BY somerow DESC LIMIT 1 OFFSET 2;

... and there are multiple rows in sometable where somerow is identical,
am I assured that the values will always come back in the same order?
...... Or do I need to ensure that a second sort (such as the oid?) is used?


Thanks!

- Greg




---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match


Reply With Quote
  #2  
Old   
Martijn van Oosterhout
 
Posts: n/a

Default Re: Sorting, when values are equal.... - 10-25-2004 , 07:46 AM






On Mon, Oct 25, 2004 at 04:45:15AM -0700, Net Virtual Mailing Lists wrote:
Quote:
Hello,


If I do something like:

SELECT * FROM sometable ORDER BY somerow DESC LIMIT 1 OFFSET 2;

.. and there are multiple rows in sometable where somerow is identical,
am I assured that the values will always come back in the same order?
..... Or do I need to ensure that a second sort (such as the oid?) is used?
No order in guarenteed or implied unless you specify it. So you'll need
another field to order by, generally the primary key works well..
--
Martijn van Oosterhout <kleptog (AT) svana (DOT) org> http://svana.org/kleptog/
Quote:
Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
tool for doing 5% of the work and then sitting around waiting for someone
else to do the other 95% so you can sue them.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQFBfPW0Y5Twig3Ge+YRAtLUAKC+RrJCjizFMfkXyukavx 70P2M7BgCgkkOU
k+c0jm58qCot0J+mzQV6gmo=
=c8vS
-----END PGP SIGNATURE-----



Reply With Quote
  #3  
Old   
Peter Eisentraut
 
Posts: n/a

Default Re: Sorting, when values are equal.... - 10-25-2004 , 10:31 AM



Net Virtual Mailing Lists wrote:
Quote:
If I do something like:

SELECT * FROM sometable ORDER BY somerow DESC LIMIT 1 OFFSET 2;

.. and there are multiple rows in sometable where somerow is
identical, am I assured that the values will always come back in the
same order? .....
No.

Quote:
Or do I need to ensure that a second sort (such as
the oid?) is used?
Yes.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.