Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: select distinct values

RE: select distinct values

From: Robson, Peter <pgro_at_bgs.ac.uk>
Date: Thu, 25 Sep 2003 01:44:40 -0800
Message-ID: <F001.005D0F85.20030925014440@fatcity.com>


Whoa there!

See below:

> -----Original Message-----
> From: elain he [mailto:elainhe_at_hotmail.com]
> Sent: Tuesday, September 23, 2003 9:40 PM
> To: Multiple recipients of list ORACLE-L
> Subject: select distinct values
>
>
> Hi,
> Could someone shed some light on this.
>
> I'm trying to formulate a query to return distinct value on a
> column -
> testid.
>
> select * from testing;
> TESTID NAME STATUS
> ---------- -------------------- -----------
> 1 MIKE Y
> 1 JOE Y
> 1 JIM Y
> 2 AMY Y
>
> The output I'm expecting is
> TESTID NAME STATUS
> ---------- -------------------- -----------
> 1 MIKE Y
> 2 AMY Y
>


This sentance contains a fundamental error of understanding of a relational db.
>
> The query should display the first occurence of the testid and ignore
> records with the same testid.
>

The ORDER in which rows are retrieved from a table is not, never, ever will be significant. By definition.

So if you can find a script which appears to give you the correct result for this example, then sure as eggs is eggs, it will fail on another data set. There is NOTHING in your example data set which enables a logical predicate to establish precedence of any one row with Testid=1 over another.

peter
edinburgh


> thanks!
>
> elain
>
> _________________________________________________________________
> Instant message in style with MSN Messenger 6.0. Download it
> now FREE!
> http://msnmessenger-download.com
>
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.net
> --
> Author: elain he
> INET: elainhe_at_hotmail.com
>
> Fat City Network Services -- 858-538-5051 http://www.fatcity.com
> San Diego, California -- Mailing list and web hosting services
> ---------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from). You may
> also send the HELP command for other information (like subscribing).
>



This e-mail message, and any files transmitted with it, are confidential and intended solely for the use of the addressee. If this message was not addressed to you, you have received it in error and any copying, distribution or other use of any part of it is strictly prohibited. Any views or opinions presented are solely those of the sender and do not necessarily represent those of the British Geological Survey. The security of e-mail communication cannot be guaranteed and the BGS accepts no liability for claims arising as a result of the use of this medium to transmit messages from or to the
BGS. .                            http://www.bgs.ac.uk
*********************************************************************

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Robson, Peter
  INET: pgro_at_bgs.ac.uk

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Thu Sep 25 2003 - 04:44:40 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US