Re: Distinct in query results in wrong order by

From: TurkBear <john.greco_at_dot.state.mn.us>
Date: Fri, 20 Jun 2003 12:10:29 -0500
Message-ID: <asf6fv00gubt837uejsoe7rc97rcrbr437_at_4ax.com>


Let's find out:



SQL> create table drop_me (
  2 a number(1),
  3 b number(1));

  1* insert into drop_me values(1,1)
SQL> / 1 row created.

SQL> c/1,1/1,2/
  1* insert into drop_me values(1,2)
SQL> / 1 row created.

SQL> c/1,2/2,1/
  1* insert into drop_me values(2,1)
SQL> / 1 row created.

SQL> c/2,1/2,2/
  1* insert into drop_me values(2,2)
SQL> / 1 row created.

SQL> select a from drop_me order by b;

         A


         1
         2
         1
         2

SQL> select a,b from drop_me order by b;

         A B
---------- ----------

         1          1
         2          1
         1          2
         2          2
-------------------------------------------------------------------------------------------------------------------------------------------

Looks sorted by B in both cases...

andrewst <member14183_at_dbforums.com> wrote:

>
>Originally posted by Sal
>> Competitor DBMS products allow you to sort by any column to like,
>> whether in the select list or not.
>>
>>
>> Sal
>Do they? So given this table T:
>
>A B
>- -
>1 1
>1 2
>2 1
>2 2
>
>What would be the result of:
>
>select distinct a
>from t
>order by b;
>
>In what sense could the result be "ordered by b"?

----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =--- Received on Fri Jun 20 2003 - 19:10:29 CEST

Original text of this message