473,406 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Sorting, when values are equal....

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

Nov 23 '05 #1
2 1950
On Mon, Oct 25, 2004 at 04:45:15AM -0700, Net Virtual Mailing Lists wrote:
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 <kl*****@svana.org> http://svana.org/kleptog/ 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-----

Nov 23 '05 #2
Net Virtual Mailing Lists wrote:
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.
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

Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
by: mike | last post by:
If I had a date in the format "01-Jan-05" it does not sort properly with my sort routine: function compareDate(a,b) { var date_a = new Date(a); var date_b = new Date(b); if (date_a < date_b)...
3
by: SilverWolf | last post by:
I need some help with sorting and shuffling array of strings. I can't seem to get qsort working, and I don't even know how to start to shuffle the array. Here is what I have for now: #include...
3
by: Daniel Weinand | last post by:
hello ng, i have a problem and a imho an insufficient method of solution. strings should be sorted by specific text pattern and dispayed in groups. the strings are stored in a db and have the...
2
by: awiklund | last post by:
Hi, I am sorting an arrayList using a custom comparer, but it sort the element in a uncommon fashion. Take a look at this code. using System; namespace ConsoleApplication8
19
by: Owen T. Soroke | last post by:
Using VB.NET I have a ListView with several columns. Two columns contain integer values, while the remaining contain string values. I am confused as to how I would provide functionality to...
7
by: Noah Roberts | last post by:
I know there must be a way to do this using stl functions and not reinventing the sort loops and such but I need to sort several arrays side by side using one as the "key". Interested in ideas...
16
by: Kittyhawk | last post by:
I would like to sort an Arraylist of objects on multiple properties. For instance, I have a Sort Index property and an ID property (both integers). So, the results of my sort would look like this:...
9
by: robin9876 | last post by:
I have a list of integers (example sub set of data below), what is the best method of sorting these in code? 1, 872 5, 1283 8, 343 9, 123
2
by: wing ver ka gundam | last post by:
THanks~ this is the example and my quote are below Write a program in JAVA that allows the user to input 5 ints. The program will then output these five values in reverse order. The program will...
11
by: Thomas Heller | last post by:
Does Python 3 have no way anymore to sort with a comparison function? Both .sort() and sorted() seem to accept only 'key' and 'reverse' arguments, the 'cmp' argument seems to be gone. Can that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.