Friday, March 23, 2012

Order by clause

If I use the order by clause to sort on a date, where the date and
time stamp are the exact same for multiple records, how does SQL
output the data?
At random... or does it look at the primary key?"Chirag Patel" <romeo9225@.yahoo.com> wrote...
> If I use the order by clause to sort on a date, where the date and
> time stamp are the exact same for multiple records, how does SQL
> output the data?
> At random... or does it look at the primary key?

Generally speaking these behaviors are considered "undefined". As such you
cannot rely on it even if it "appears" to always do the same thing and if
you absolutely need the set ordered then you have to include it in the order
clause.

No comments:

Post a Comment