3 messages in com.mysql.lists.win32Re: GROUP BY and ORDER BY priority
FromSent OnAttachments
targeted22 Sep 1999 02:25 
Bob Kline22 Sep 1999 04:57 
Michael Widenius22 Sep 1999 06:27 
Subject:Re: GROUP BY and ORDER BY priority
From:Bob Kline (bkl@rksystems.com)
Date:09/22/1999 04:57:15 AM
List:com.mysql.lists.win32

On Wed, 22 Sep 1999, targeted wrote:

Hello !

assume that we have the following table (TBL):

I(Autoincrement) T(TimeStamp) F(Integer) 1 1999-09-01 1 2 1999-09-02 2 3 1999-09-03 1

------------------------------------------ Now issue SELECT F FROM TBL GROUP BY F;

We get 1 2 of course (what else ? :)

------------------------------------------ Now issue SELECT F FROM TBL GROUP BY F ORDER BY T;

And get 1 2 this is still comprehensive :)

------------------------------------------ Now issue SELECT F FROM TBL GROUP BY F ORDER BY T DESC;

And get 2 1 This is very strange, taking into account the previous query (without DESC). Why isn't it 1,2 as well ?

This means that the result of the query is not identical if you reverse the data in the table and use DESC everywhere :)

How can this be fixed ? Or how can I get 1, 2 from the later query ?

If you issue queries like the latter two, you pretty much have to take what you get.