只有10分了,多谢表结构
id score
1 5
2 2
3 3
4 3
分数为5个级别:分别为1,2,3,4,5现在统计5分的一共多少人,4分的多少人,3,2,1比如"
5分,157,76%
4分,10,5%
3分,17,8%
2分,2,1%
1分,21,10%现在这查询语句我写不出来,高手帮忙,因为写不出来我就没有办法把结果绑定报表,狂谢!
id score
1 5
2 2
3 3
4 3
分数为5个级别:分别为1,2,3,4,5现在统计5分的一共多少人,4分的多少人,3,2,1比如"
5分,157,76%
4分,10,5%
3分,17,8%
2分,2,1%
1分,21,10%现在这查询语句我写不出来,高手帮忙,因为写不出来我就没有办法把结果绑定报表,狂谢!
(select id,sum(score) as score from T1 group by id) as a,(select sum(score) as sumscore from T1) as b没有测试过。。~~
5分,157人,76%
4分,10人,5%
3分,17人,8%
2分,2人,1%
1分,21人,10%分数那里没有统计出对应有多少人?%号那里全是0%,不知道select语句能写的出不
from a
group by score
insert #test select 1,5
union all select 2,2
union all select 3,3
union all select 4,5
union all select 5,1
union all select 6,3
union all select 7,3
union all select 8,5
union all select 9,1select a.score,cast(a.ROW/b.sumscore as varchar(10)) +'%' from
(SELECT A.SCORE,(SUM(B.SCORE)/A.SCORE) AS ROW FROM (SELECT SCORE FROM #TEST GROUP BY SCORE) A LEFT JOIN #TEST B ON A.SCORE=B.SCORE GROUP BY A.SCORE) AS A,
(SELECT COUNT(*) AS SUMSCORE FROM #TEST) AS B