呵呵~~ 再跟select * from (
select deptlevel1,deptlevel2,deptlevel3,peoples,1 ord1,1 ord2,1 ord3 from T001
union 
select deptlevel1,deptlevel2,'小计',sum(peoples),1,1,2  from T001 Group by deptlevel1,deptlevel2
union 
select deptlevel1,'合计','',sum(peoples),1,2,2  from T001 group by deptlevel1
union
select '总计','','',sum(peoples),2,2,2  from t001 
) tb order by tb.ord1,deptlevel1,tb.ord2,deptlevel2,tb.ord3,deptlevel3

解决方案 »

  1.   

    至于行的颜色,在DataGrid的ItemDataBound事件里控制
    if(e.Item.ItemIndex>-1)
    {
       if(e.Item.Cells[0].Text = "总计")
         e.Item.BackColor = System.Drawing.Color.Red;
       if(e.Item.Cells[1].Text = "合计")
         e.Item.BackColor = System.Drawing.Color.Yellow;
       if(e.Item.Cells[2].Text = "小计")
         e.Item.BackColor = System.Drawing.Color.Blue;
    }