How to delete the following repeated data ?
my table :
Name Salary
--
Abc 20000
Abc 10000
CDE 01000
XYZ 12000
VID 30233
XYZ 40000
from the above table I want to delete repeated record 'Abc' and XYZ so that I should have the following records
Name Salary
--
Abc 20000
CDE 01000
XYZ 12000
VID 30233
Is it possible ?
Adv. thanks
bye
muralidharan T RYou need to be specific about which rows you wish to delete. If, for example, you want to delete all but the highest salary for each name:
delete from myTable
where Salary < (
select max(Salary) from myTable as T2
where T2.Salary > myTable.Salary
)
Steve Kass
Drew University
SQL Server MVP
No comments:
Post a Comment