求一个sql语句

IFocusYou 2011-04-13 06:29:12
Name value
张三 1
张三 4
李四 5
李四 8
王五 3



select 后


张三 4
李四 8
王五 3
...全文
133 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
wwwwb 2011-04-14
  • 打赏
  • 举报
回复
假设VALUE唯一
select `name`,max(`values`) from tt group by `name`
or
select * from tt A
where not exists (select 1 from A.`name`=`name` and A.`value`<`value`)
guojiguoye 2011-04-14
  • 打赏
  • 举报
回复
mysql>select name,max(value) from tbl_name group by name;
rucypli 2011-04-13
  • 打赏
  • 举报
回复
select *
from tb A
where not exists (select 1 from A.name=name and A.value<value)
ACMAIN_CHM 2011-04-13
  • 打赏
  • 举报
回复
参考下贴中的多种方法

http://topic.csdn.net/u/20091231/16/2f268740-391e-40f2-a15e-f243b2c925ab.html
[征集]分组取最大N条记录方法征集,及散分....
ACMAIN_CHM 2011-04-13
  • 打赏
  • 举报
回复
select name,max(`values`) from table1 group by name

56,687

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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