SQL 语句。。等待中

rwx6 2005-03-25 01:40:51
有表TABLE,列为:EMPID NAME
EMPID NAME
1 A
2 B
3 B
4 A
5 C
6 D
1,把有重复的行选出来
2,删除有重复的行(只显示一行)
...全文
104 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
纸飞机2017 2005-03-25
  • 打赏
  • 举报
回复
删除:Delete from table where Empid not in (select Empid from table where name in (select NAME from table group by NAME having count(NAME ) > 1 group by name))

把没重复的记录全删掉了
xyqiqi 2005-03-25
  • 打赏
  • 举报
回复
显示一行: select NAME from table group by NAME having count(NAME ) > 1
显示重复行中所有记录select * from table where name in (select NAME from table group by NAME having count(NAME ) > 1 group by name)
删除:Delete from table where Empid not in (select Empid from table where name in (select NAME from table group by NAME having count(NAME ) > 1 group by name))
nimittz 2005-03-25
  • 打赏
  • 举报
回复
只要显示吗,用select distinct
hygougou 2005-03-25
  • 打赏
  • 举报
回复
删除,用delete
就不知道你要删除哪行了???
hygougou 2005-03-25
  • 打赏
  • 举报
回复
select NAME, count(*) from table group by NAME having count(*) > 1
peixun 2005-03-25
  • 打赏
  • 举报
回复
你想实现什么功能?说出来听听
rwx6 2005-03-25
  • 打赏
  • 举报
回复
empid为主键, 对,楼上的理解正确
hygougou 2005-03-25
  • 打赏
  • 举报
回复
是要把哪个字段有重复的行删除吧?


你的表没主键如何设置的

611

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder DataWindow
社区管理员
  • DataWindow社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧