Re: why the result of the query is in asending order
- From: bhavik <bhavik@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 19 Apr 2005 01:43:04 -0700
Hi, Hugo
thanks for ur kind reply
what u suggest me, will not solve my problem
i want to do exactly reverse of this
I dont want my data(result of query)to be order by.
i want to know why sql server returns me data in order by
Pravin
"Hugo Kornelis" wrote:
> On Mon, 18 Apr 2005 04:21:02 -0700, bhavik wrote:
>
> (snip)
> >i want my result to be
> >
> >in the following way(which is the actual order in routesegment : desirable)
> >
> >
> >locationname locationid
> >---------------------------------------
> >Gallery 20
> >loc2 25
> >loc1 24
> >WP2 27
> >WP1 26
> >wp3 28
> >
> >
> >why the result of the query is in asending order
>
> Hi Pravin,
>
> Since you didn't specify an ORDER BY clause in your query, SQL Server is
> free to return the rows in any order it sees fit. The optimizer will
> create an execution plan that will minimize the execution time, without
> regard for the order in which rows are returned. Explaining why this
> particular order is used requires full knowledge of your tables, all
> indexes, statistics about numbers of rows and data distribution, details
> of your server, other processes running at the same time and a fair
> amount of guessswork.
>
> >
> >is ther any solution
>
> The only way to make sure you get the rows in the order you need them is
> to specify an ORDER BY clause. I'm not sure if I understand your data
> correctly, but I *think* that this one will return the rows in the order
> you want them:
>
> SELECT
> distinct locationname,locationid
> FROM
> routesegment
> ,location
>
> WHERE
> (startlocation=locationid
> or
> endlocation=locationid)
> and
> routeid=@routeid
> ORDER BY rsid -- <-- Add this line
>
> Best, Hugo
> --
>
> (Remove _NO_ and _SPAM_ to get my e-mail address)
>
.
- Follow-Ups:
- Re: why the result of the query is in asending order
- From: Hugo Kornelis
- Re: why the result of the query is in asending order
- References:
- why the result of the query is in asending order
- From: bhavik
- Re: why the result of the query is in asending order
- From: Hugo Kornelis
- why the result of the query is in asending order
- Prev by Date: Re: why the result of the query is in asending order
- Next by Date: Re: why the result of the query is in asending order
- Previous by thread: Re: why the result of the query is in asending order
- Next by thread: Re: why the result of the query is in asending order
- Index(es):
Relevant Pages
|
|