Home » SQL & PL/SQL » SQL & PL/SQL » Exclude some columns in a select group by statement
Exclude some columns in a select group by statement [message #2028] Mon, 17 June 2002 21:55 Go to next message
ajay
Messages: 45
Registered: December 2000
Member
I am selecting a set of 10 columns. the table to which I am inserting has 4 columns as primary key...
When I retrieve I get duplicates keys failure as some duplicate records are getting selected...

Within the SQL statement how I can I ensure that I retrieve only unique records for the primary key combination ?
Re: Exclude some columns in a select group by statement [message #2030 is a reply to message #2028] Mon, 17 June 2002 23:02 Go to previous messageGo to next message
Balaji
Messages: 102
Registered: October 2000
Senior Member
did'nt quite understand the problem
anyway in order to avoid the duplicate u can use
either unique or distinct keyword.
Eg.
select distinct column1 from table1.

balaji
Re: Exclude some columns in a select group by statement [message #2032 is a reply to message #2028] Tue, 18 June 2002 05:10 Go to previous message
lakshmi
Messages: 22
Registered: July 2000
Junior Member
try this .. this will eliminate the duplicate records

delete from table_name
where rowid in (select a.rowid from table_name a,table_name b
where a.rowid < b.rowid
and a.primary_key1 = b.primary_key1
and a.primary_key2 = b.primary_key2
and a.primary_key3 = b.primary_key3
and a.primary_key4 = b.primary_key4
Previous Topic: Stored Procedure problem
Next Topic: SQL Query
Goto Forum:
  


Current Time: Tue Apr 23 06:28:42 CDT 2024