Re: DISTINCT and ORDER BY
From: Steve Kass (skass_at_drew.edu)
Date: 08/05/04
- Next message: Joe Celko: "Re: Need a query"
- Previous message: Danny: "Re: CONTAINS ignore "Fahrenheit"?"
- In reply to: Sunny: "Re: DISTINCT and ORDER BY"
- Next in thread: Sunny: "Re: DISTINCT and ORDER BY"
- Reply: Sunny: "Re: DISTINCT and ORDER BY"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 04 Aug 2004 23:20:41 -0400
Sunny,
Am I correct to understand that you are executing a query *without*
ORDER BY in it, and you are getting this error?
[SQL Server]ORDER BY items must appear in the select list if SELECT
DISTINCT is specified.
It is not easy to see how that can happen, since this message should
only appear for a query that contains ORDER BY.
Are you running this query alone with no other statements? Have you
tried running the query in Query Analyzer?
Steve Kass
Drew University
Sunny wrote:
>In article <r2s2h0dh4tib6r7vfs1ur4p9qpep0aikvv@4ax.com>,
>hugo@pe_NO_rFact.in_SPAM_fo says...
>
>
>>Hi Sunny,
>>
>>In the relational model, a table is by definition an UNordered collection
>>of rows. Even using order by doesn't guarantee that the rows will be
>>inserted in the order you specify. And even if they are, you still have no
>>guarantee that they will be SELECTed in the same order.
>>
>>ORDER BY really only should be used in a SELECT statement. It specifies
>>the order that the result set has to be sorted into before displaying.
>>
>>So you can simply remove the ORDER BY clause and you'll no longer have the
>>error message. I know this doesn't explain the error, but it does solve
>>it!
>>
>>Best, Hugo
>>
>>
>>
>
>Hi Hugo,
>thanks for the replay. The problem is that I do not need order. I put it
>there, because it gave me the same error without the ORDER BY.
>
>I Just want to get a subset of one table and put it in another. Please,
>see my second post, there I have simplified the INSERT statement, and
>still it fails with the same error. I tried to remove the ORDER By, and
>still the same problem.
>
>Thanks again
>Sunny
>
>
- Next message: Joe Celko: "Re: Need a query"
- Previous message: Danny: "Re: CONTAINS ignore "Fahrenheit"?"
- In reply to: Sunny: "Re: DISTINCT and ORDER BY"
- Next in thread: Sunny: "Re: DISTINCT and ORDER BY"
- Reply: Sunny: "Re: DISTINCT and ORDER BY"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|