table1中有工号和姓名,工号是主键,现在的问题是如何查询出重名的员工记录(不重名的不要),显示字段包括工号和姓名(50分)

  • 主题发起人 々飞翔鸟々
  • 开始时间

々飞翔鸟々

Unregistered / Unconfirmed
GUEST, unregistred user!
table1中有工号和姓名,工号是主键,现在的问题是如何查询出重名的员工记录(不重名的不要),显示字段包括工号和姓名
 
Select * From Table1 Where 姓名 in (Select 姓名 From Table1 Group by 姓名)
 
select * from table1 where name in
(select name from table1 group by name having count(name)>1)
 
楼上正解,我漏写了
 
select 工号,姓名 from table1 a where (select count(*) from table1 where name=a.name)>1
 
多人接受答案了。
 

Similar threads

S
回复
0
查看
1K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
926
SUNSTONE的Delphi笔记
S
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
1K
DelphiTeacher的专栏
D
顶部