Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread GROUP BY / ORDER BY
Sun, May 9 2010 9:04 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

I think I'm right in assuming that the sequence for a GROUP BY clause is the same as for the equivalent ORDER BY clause but I want to make sure.

Roy Lambert
Mon, May 10 2010 1:23 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< I think I'm right in assuming that the sequence for a GROUP BY clause is
the same as for the equivalent ORDER BY clause but I want to make sure. >>

The order of the expressions in either clause is completely up to you, so
I'm not sure what you're asking.  Could you elaborate on what you mean by
"sequence" in your case ?

--
Tim Young
Elevate Software
www.elevatesoft.com
Tue, May 11 2010 3:40 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim

><< I think I'm right in assuming that the sequence for a GROUP BY clause is
>the same as for the equivalent ORDER BY clause but I want to make sure. >>
>
>The order of the expressions in either clause is completely up to you, so
>I'm not sure what you're asking. Could you elaborate on what you mean by
>"sequence" in your case ?

Just grabbing a convenient example does having

GROUP BY _PNO,COALESCE(_Result,'-'),COALESCE(_Analysis,'-')

require order the query essentially in the same sequence as

ORDER BY _PNO,COALESCE(_Result,'-'),COALESCE(_Analysis,'-')

Reading between the lines of your reply I can use a different ORDER BY clause to re-sequence the data produced by the GROUP BY clause. The amount I have still to learn never fails to astound me.

Roy Lambert


Tue, May 11 2010 3:01 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< Just grabbing a convenient example does having

GROUP BY _PNO,COALESCE(_Result,'-'),COALESCE(_Analysis,'-')

require order the query essentially in the same sequence as

ORDER BY _PNO,COALESCE(_Result,'-'),COALESCE(_Analysis,'-') >>

Okay, that's what I thought you meant, but I wanted to be sure.  Yes, you
can have a completely different ORDER BY sequence from the GROUP BY
sequence.

--
Tim Young
Elevate Software
www.elevatesoft.com
Image