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

Home -> Community -> Usenet -> c.d.o.server -> Re: Query

Re: Query

From: Niall Litchfield <n-litchfield_at_audit-commission.gov.uk>
Date: Mon, 11 Mar 2002 11:46:17 -0000
Message-ID: <3c8c990a$0$8514$ed9e5944@reading.news.pipex.net>


SQL> create table test(col1 number,col2 varchar2(30));

Table created.

SQL> insert into test values(1,'Oracle');

1 row created.

SQL> / 1 row created.

SQL> insert into test values(2,'Oracle');

1 row created.

SQL> commit;

Commit complete.

SQL> select * from test
  2 ;

      COL1 COL2

---------- ------------------------------
         1 Oracle
         1 Oracle
         2 Oracle

SQL> select col1,col2
  2 from
  3 (select col1,col2 from test group by col1,col2);

      COL1 COL2

---------- ------------------------------
         1 Oracle
         2 Oracle

SQL> select distinct col1||' '||col2 from test;

COL1||''||COL2



1 Oracle
2 Oracle

SQL>

--
Niall Litchfield
Oracle DBA
Audit Commission UK
*****************************************
Please include version and platform
and SQL where applicable
It makes life easier and increases the
likelihood of a good answer

******************************************
"Gopal" <oracleinform_at_yahoo.com> wrote in message
news:1ed02c3a.0203110314.64225045_at_posting.google.com...

> Hi,
>
> How to use distinct on 2 columns . For eg I have a table A with 2
> columns
>
> A B
>
> 1 Oracle
> 1 Oracle
> 2 ORACLE
>
> In the above example first 2 records 2 columns are equal hence I want
> only 1 record out of the 2 records , How to imply distinct on such
> records , not using the rowid .
>
> Rgds
Received on Mon Mar 11 2002 - 05:46:17 CST

Original text of this message

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