Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: select distinct values
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).
>
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