征求sql语句 一个表里有很多个人的成绩 然后我想把每个人的最好成绩都选出来 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select *from 成绩表 twhere not exists(select * from tb where 姓名=t.姓名 and 成绩>t.成绩)如果成绩表里没有姓名就用学号 http://blog.chinaunix.net/u/29134/showart_411484.html 如果你的表的成绩表是放在一个字段里的 像这样表aaa id(自增长主键) uid(用户id) chengji(成绩) kemu(科目)类似这样的表结构的话那么使用max即可实现你的功能比如:select max(chengji) from aaa where uid = 666如果你的表结构像这样表bbb uid(用户id) chengji1(科目一成绩) chengji2(科目2成绩) chengji3(科目3成绩)我暂时还不知道怎么写,另外我认为这样的表结构是不合理的 select max(chengji) from tblname group by userid 补充一下我刚才发的帖子第二个方案的解决方法,我找到了答案,哈哈求某几列中最大值 select greatest(col1,col2,col3...) from tablename; 求某几列中最小值 select least(col1,col2,col3...) from tablename; 外键问题求解决! mysql innodb_buffer_pool的预加载 PostgreSQL 如何字符串解析成表? 求MySQL语句写法 请教:MYSQL插入数据报错 postgres 中数据类型转换 请问mysql里怎样让字段自动自增? 三表关联查询 抛砖引玉::我们翻译MySQL参考手册如何? mysql安装问题 如何修改一个字段的部分数据 postgresql 存储结构返回问题
from 成绩表 t
where not exists(select * from tb where 姓名=t.姓名 and 成绩>t.成绩)如果成绩表里没有姓名就用学号
像这样表aaa id(自增长主键) uid(用户id) chengji(成绩) kemu(科目)
类似这样的表结构的话那么使用max即可实现你的功能
比如:
select max(chengji) from aaa where uid = 666如果你的表结构像这样
表bbb uid(用户id) chengji1(科目一成绩) chengji2(科目2成绩) chengji3(科目3成绩)
我暂时还不知道怎么写,另外我认为这样的表结构是不合理的
求某几列中最大值
select greatest(col1,col2,col3...) from tablename;
求某几列中最小值
select least(col1,col2,col3...) from tablename;