declare @t table(总分 numeric(5,3),人数 int,题号 int,分值 numeric(5,3),年 int,月 int)
insert into @t select 0.001 ,1,1,0.001 ,2006,2
insert into @t select 1.000 ,1,1,1.000 ,2006,2
insert into @t select 4.000 ,2,1,2.000 ,2006,2
insert into @t select 3.000 ,1,1,3.000 ,2006,2
insert into @t select 4.000 ,1,1,4.000 ,2006,2
insert into @t select 10.000,2,1,5.000 ,2006,2
insert into @t select 12.000,2,1,6.000 ,2006,2
insert into @t select 7.000 ,1,1,7.000 ,2006,2
insert into @t select 9.000 ,1,1,9.000 ,2006,2
insert into @t select 10.000,1,1,10.000,2006,2
insert into @t select 10.000,1,2,10.000,2006,2
insert into @t select 8.000 ,1,3,8.000 ,2006,2
insert into @t select 5.000 ,1,5,5.000 ,2006,2
insert into @t select 4.000 ,1,8,4.000 ,2006,2
insert into @t select 1.000 ,1,8,1.000 ,2006,2select 题号,avg(人数*分值) 平均得分 from @t group by 题号/*
题号 平均得分
----------- ---------
1 6.000100
2 10.000000
3 8.000000
5 5.000000
8 2.500000
*/
insert into @t select 0.001 ,1,1,0.001 ,2006,2
insert into @t select 1.000 ,1,1,1.000 ,2006,2
insert into @t select 4.000 ,2,1,2.000 ,2006,2
insert into @t select 3.000 ,1,1,3.000 ,2006,2
insert into @t select 4.000 ,1,1,4.000 ,2006,2
insert into @t select 10.000,2,1,5.000 ,2006,2
insert into @t select 12.000,2,1,6.000 ,2006,2
insert into @t select 7.000 ,1,1,7.000 ,2006,2
insert into @t select 9.000 ,1,1,9.000 ,2006,2
insert into @t select 10.000,1,1,10.000,2006,2
insert into @t select 10.000,1,2,10.000,2006,2
insert into @t select 8.000 ,1,3,8.000 ,2006,2
insert into @t select 5.000 ,1,5,5.000 ,2006,2
insert into @t select 4.000 ,1,8,4.000 ,2006,2
insert into @t select 1.000 ,1,8,1.000 ,2006,2select 题号,avg(人数*分值) 平均得分 from @t group by 题号/*
题号 平均得分
----------- ---------
1 6.000100
2 10.000000
3 8.000000
5 5.000000
8 2.500000
*/
解决方案 »
- 关于触发器的
- 两个表求差如何求呀?
- 问一个非常奇怪的问题,关于一条极简单的查询语句
- 取得最新数据
- 求解:win7 (windows 7)下SQL Server管理器无法连接到远程SQL数据库
- SQL查询表中字段名
- 连接问题!
- 有这样的SQL工具吗?还是要编写一个应用程序?
- 大家好,我想请问一下如何选定一个SQL Server数据库中的几个表,将这几个表输出到一个Excel文件?要VB代码实现或用SQL Server的编程来实现?谢谢!
- 请问SQL Server2000里有没有数组变量?
- 求助一条类似Oracle中rownum的SQL函数?
- 不能用insert into #temp select pid from...向带有自增列的临时表中插入数据??
=0.001)/10 as 得分率 from aa b group by 题号
from @t group by 题号
lsqkeke(可可) 和duoluohuifeng(堕落回风)方法经果都对!