|
Ha ha, did I understand the wrong landlord? This question is not difficult.
create table #table
(
[Student ID] varchar(5),
[Name] varchar(20),
[Gender] varchar(2),
[Age] int
)
--drop table #table
insert into #table ([Student ID],[Name],[Gender],[Age])
select '0001','xw','Male',18 union all
select '0002','mc','Female',18 union all
select '0003','mc','Female',18 union all
select '0004','mc','Female',18 union all
select '0005','ww','Male',21 union all
select '0006','xw','Male',18 union all
select '0007','xw','Male',18
--Show what needs to be kept
select min (student number), [name], [gender], [age] from #table
group by [name], [gender], [age] order by min (student number)
- delete the ones that do not need to be kept
delete --select *
from #table
where [Student ID] not in (select min(Student ID) from #table
group by [name], [gender], [age]) |
|