首页 新闻 会员 周边

RDLC报表分组问题

0
[已解决问题] 解决于 2009-11-10 09:25

我有一张表,有以下字段

sid,自动增长(主键)

name,姓名

sex,性别

sclass,班级

score,成绩

现在想在RDLC报表中做如下汇总,可有办法?

  分数
合计  
1班合计  
2班合计  
男生合计  
女生合计  

 

我试了很久,也没找到办法...

问题补充: 感谢dege301的回答. 这个应该是可以的. 但班级不是固定的,可能会有3班,4班之类的,这样就没办法处理了. 我想在rdlc报表中用分组,但分了一个班级组后,性别组默认就是班级组的子组了..无法实现平行的两级汇总. 还不是想要的效果.不过还是感谢各位.
Pwd的主页 Pwd | 初学一级 | 园豆:158
提问于:2009-11-09 11:43
< >
分享
最佳答案
0

一个笨方法(用报表的自带分组应该也可以,俺还没弄明白):

  sql:

    declare @tbl table(sname varchar(50),score decimal(18,1))
    Insert Into @tbl Select '汇总',sum(score) from ope_scoregroup
    Insert Into @tbl Select sclass,sum(score) from ope_scoregroup group by sclass
    Insert Into @tbl Select '男生',sum(score) from ope_scoregroup where sex = 1
    Insert Into @tbl Select '女生',sum(score) from ope_scoregroup where sex = 0
    select * from @tbl

  布局直接用表格就行了

    

  效果

    

窃马贼 | 初学一级 |园豆:145 | 2009-11-09 16:34
其他回答(1)
0

可以的,4行对应4个查询用Union联合到一块,详细如下:

select '1班合计' as flag,sum(score) as 分数 where sclass=1

 Union

select '2班合计',sum(score) where sclass=2

Union

select '男生合计' ,sum(score) where sex='男'

Union 

select '女生合计' ,sum(score) where sex='女'

这样应该没问题了。

dege301 | 园豆:2825 (老鸟四级) | 2009-11-09 12:46
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册