Home » SQL & PL/SQL » SQL & PL/SQL » question on DISTINCT
question on DISTINCT [message #9159] Thu, 23 October 2003 03:15 Go to next message
siva
Messages: 58
Registered: August 1999
Member
how to select distinct rows from a table,for example if there is a table x(deptno,dname) and there are duplicate tuples in deptno , how to select distinct tuples of deptno and display the table with distinct values of deptno and dname.

Thank u.
Re: question on DISTINCT [message #9160 is a reply to message #9159] Thu, 23 October 2003 05:53 Go to previous messageGo to next message
jseven
Messages: 28
Registered: October 2003
Junior Member
create table test(no number,dname varchar2(20));

SQL> select * from test;

NO DNAME
---------- --------------------
1 oper
2 mktg
1 sales

select * from test where rowid in(select max(rowid) from test group by no);

hope this works out for you
Re: question on DISTINCT [message #9193 is a reply to message #9159] Sat, 25 October 2003 15:12 Go to previous message
Barbara Boehmer
Messages: 9090
Registered: November 2002
Location: California, USA
Senior Member
SELECT DISTINCT deptno, dname FROM x;
Previous Topic: Trigger Compilation Headache
Next Topic: Error while using UTL_FILE pakage
Goto Forum:
  


Current Time: Thu Apr 25 18:41:56 CDT 2024