去除重复

airen12345678 2010-02-04 03:40:44

id name size

我要去除重复的name并且留下size数字最大的
?????
...全文
73 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
--小F-- 2010-02-04
  • 打赏
  • 举报
回复
select
*
from
tb t
where
size=(select max(size) from tb where name=t.name)
airen12345678 2010-02-04
  • 打赏
  • 举报
回复
这么快
呵呵
谢谢
Zoezs 2010-02-04
  • 打赏
  • 举报
回复

select * from tb t where not exists(select 1 from tb where name=t.name and size>t.size)
-狙击手- 2010-02-04
  • 打赏
  • 举报
回复
select name,max(size) as size from tb group by name
Mr_Nice 2010-02-04
  • 打赏
  • 举报
回复
路过,学习...
黄_瓜 2010-02-04
  • 打赏
  • 举报
回复
select * from tb t
where not exists(select 1 from tb where name=t.name and size>t.size)
百年树人 2010-02-04
  • 打赏
  • 举报
回复
如果不要显示id
select name,max(size) as size from tb group by name
快乐_石头 2010-02-04
  • 打赏
  • 举报
回复
select * from tb t
where not exists(select 1 from tb where name=t.name and size>t.size)
百年树人 2010-02-04
  • 打赏
  • 举报
回复
select *
from tb t
where not exists(select 1 from tb where name=t.name and size>t.size)

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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