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: SQL to retrieve all distinct records

Re: SQL to retrieve all distinct records

From: <ryan.gaffuri_at_cox.net>
Date: Thu, 15 Apr 2004 14:18:07 -0400
Message-Id: <20040415181809.RTCG6045.lakermmtao01.cox.net@smtp.central.cox.net>


select a.*
from (select col1||col2 col_concat, col3

       from tab1) a,
   (select distinct col1||col2 col_distinct =

     from tab1) b
where a.col_concat =3D b.concat

I think that will work. might be a better way. =

> =

> From: "Alison Barak" <ambarak_at_hotmail.com>
> Date: 2004/04/15 Thu AM 09:38:28 EDT
> To: oracle-l_at_freelists.org
> Subject: SQL to retrieve all distinct records
> =

> Hi,
> can someone assist me with formulating a query to retrieve all distinct=
 =

> records. I need to retrieve all three columns a,b &c based on the dist=
inct =

> of the two columns a & b.
> =

> SQL> select * from testing;
> A B C
> ---------- ---------- ----------
> APPS APPS R1
> SYS SYS2 R2
> SYS SYS2 R3
> DOC DOC2 R4
> DC DC2 R5
> DOC DOC R6
> =

> The result should be
> A B C
> ---------- ---------- ----------
> APPS APPS R1
> SYS SYS2 R2
> DOC DOC2 R4
> DC DC2 R5
> DOC DOC R6
> =

> =

> I tried using group by/having count but was not successful. Any idea?
> =

> Thanks.
> =

> alison
> =

> _________________________________________________________________
> MSN Toolbar provides one-click access to Hotmail from any Web page =96 =
FREE =
> download! http://toolbar.msn.com/go/onm00200413ave/direct/01/
> =

> ----------------------------------------------------------------
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> ----------------------------------------------------------------
> To unsubscribe send email to: oracle-l-request_at_freelists.org
> put 'unsubscribe' in the subject line.
> --
> Archives are at http://www.freelists.org/archives/oracle-l/
> FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
> -----------------------------------------------------------------
> =



Please see the official ORACLE-L FAQ: http://www.orafaq.com

To unsubscribe send email to: oracle-l-request_at_freelists.org put 'unsubscribe' in the subject line.
--
Archives are at http://www.freelists.org/archives/oracle-l/
FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------
Received on Thu Apr 15 2004 - 14:23:54 CDT

Original text of this message

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