Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: SQL to retrieve all distinct records
this is pretty much like selecting random rows.
see the suggestions you got so far.
there must be a well-defined query criterion
before you can think about correct SQL solutions...
Lex.
PS: if you are based in Sweden, Denmark, Belgium, or Norway (or you don't
mind to travel :-)
I suggest you attend a seminar I am teaching on April 29, April 30, May 19,
and May 28 respectively.
it is called "SQL: Writing it Right!"
-----Original Message-----
From: oracle-l-bounce_at_freelists.org
[mailto:oracle-l-bounce_at_freelists.org]On Behalf Of Alison Barak
Sent: Thursday, April 15, 2004 16:24
To: oracle-l_at_freelists.org
Subject: RE: SQL to retrieve all distinct records
I believe I have found a solution. Just wonder if anyone else has an alternative or better approach?
select * from testing where rowid in (select min(rowid) from testing group by a,b);
thanks.
alison
>From: "Alison Barak" <ambarak_at_hotmail.com>
>To: oracle-l_at_freelists.org
>Subject: SQL to retrieve all distinct records
>Date: Thu, 15 Apr 2004 09:38:28 -0400
>
>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 distinct
>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
>
-- Archives are at http://www.freelists.org/archives/oracle-l/ FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html ----------------------------------------------------------------- -- Binary/unsupported file stripped by Ecartis -- -- Type: text/x-vcard -- File: Lex de Haan.vcf ---------------------------------------------------------------- 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 - 12:53:27 CDT
![]() |
![]() |