分享到: ------解决方案-------------------- 童鞋,给你一句忠告以后再设计sql时应注意,避免让数据库为你计算,这样会让系统变得很慢,数据量大的时候还可能导致数据库服务器的down机。sql中有orderby 和 groupby这两个可以解决你的问题。自己上网上查下怎么用 ------解决方案-------------------- select a.学号,b.姓名,b.性别, sum(a.成绩)/(select coun(*) from 成绩表 ) as 平均成绩
from 成绩表 a left join 学生表 b
on a.学号 =b.学号
group by a.学号
order by sum(a.成绩) asc ------解决方案-------------------- select 学号, sum(成绩) as 总成绩, avg(成绩) as 平均成绩 from 成绩表 group by 1 order by 4
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn