select * from 表 a
order by (select sum(分数) from 表 where 学号=a.学号)
解决方案 »
- 有哪位大神知道这个代码的错误?错误提示必须声明标量变量@MyProductID
- sql2000升级到sql2005
- SQL SERVER 中的"页"的概念有详细的资料吗?
- 关于数据库模糊查询的问题???
- 急急急sql sever2008安装出现未知属性错误问题求高手解决
- 在表中怎么表示一个数据范围?比如:大于32小于40,这个范围怎么存
- 将一个库存为sql脚本文件,但是为何运行总是出错?
- 这个表的别名怎么写?
- 如何将网页(特别是图形图像)存入sql2000数据库,如何调出并能在网页上正常显示图形图像?
- 关系数据库的备份问题???
- 使用 Enterprise Manager 产生SQL的疑问,关于脚本产生的先后次序。
- 请问这样的SQL语句该怎么写?
create table 表(姓名 varchar(10),学号 char(4),分数 int,课程 varchar(10))
insert 表 select 'a','1100',97,'数学'
union all select 'a','1100',70,'英语'
union all select 'a','1100',80,'政治'
union all select 'b','1102',66,'数学'
union all select 'b','1102',77,'英语'
go--查询
select * from 表 a
order by (select sum(分数) from 表 where 学号=a.学号)
go--删除测试
drop table 表/*--测试结果
姓名 学号 分数 课程
---------- ---- ----------- ----------
b 1102 66 数学
b 1102 77 英语
a 1100 97 数学
a 1100 70 英语
a 1100 80 政治(所影响的行数为 5 行)
--*/
order by (select sum(分数) from 表 where 学号=a.学号) desc
from xs_tab a
,(select xh,sum(fs) zf from xs_tab group by xh) b
where a.xh=b.xh
order by b.zf
升降序自己确定
from 表
group by 姓名,学号
order by sum(分数) desc
from 表
group by 姓名,学号
order by avg(分数) desc平均分 还更合理些!咣当是谁拿砖头砸我?有种站出来!