Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

eliminate duplicate records 1

Status
Not open for further replies.

jshanoo

Programmer
Apr 2, 2002
287
0
0
IN
HIi all,
Please find thee sql stmt:

'Select code,Name from class
order by code'
In resultset i get dupliacte records
only the code is duplicating the name field is different.
i want keep only one record of the two; if code '4' has two records then i need only one of them. so the code field is not duplicated.

Please advice me.
JOhn
i get following result set
'
258752 COMPUTER CDR-HP
258752 HP-COMPUTER CDR
258753 COMPUTER CDR-BASF
258753 BASF-COMPUTER CDR
258754 COMPUTER CDR-SAMSUNG
258754 SAMSUNG-COMPUTER CDR
258755 COMPUTER CDR W-SONY
258755 SONY-COMPUTER CDR W
258756 COMPUTER CDR W-IMATION
258756 IMATION-COMPUTER CDR W
258757 COMPUTER CDR W-HP
258757 HP-COMPUTER CDR W
258758 COMPUTER CDR W-SAMSUNG
258758 SAMSUNG-COMPUTER CDR W
258759 COMPUTER CDR W-BASF
258759 BASF-COMPUTER CDR W
258760 COMPUTER FLOPPY BOX-SONY
258760 SONY-COMPUTER FLOPPY BOX




*** Even the Best, did the Bad and Made the Best ***

John Philip
 
select DISTINCT code, Name
from class
order by code


I was standing in the park, wondering why frisbees got bigger as they came closer... then it hit me!
 
hi, Sorry for the late reply.
This will not give me teh required result, it will be same as that of rceords.
duplication i shappening only with code not with name.
so distinct will not work

Regards
John Philip

*** Even the Best, did the Bad and Made the Best ***

John Philip
 
Code:
select code,max(name)
from class
group by code
order by code
 
hi swamp boogie,
Eureka.
i made it.

Regards
John Philip

*** Even the Best, did the Bad and Made the Best ***

John Philip
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top