- 论坛徽章:
- 0
|
谢谢楼上的.不过那样不行.不能分组统计出来.
我使用
select 单据号,姓名,生日,护照,目的,c.费用 from
( select 1 as kk ,单据号,姓名,生日,护照,目的,c.费用,c.费用id
from b, a,c
where b.单据号=a.单据号 and a.费用id = c.费用id
union all
select 2 as kk ,'','','合计', count(1) as '名',count(distinct 单据号) as '批',sum(c.费用),c.费用id
from b, a,c
where b.单据号=a.单据号 and a.费用id = c.费用id
group by a.费用id
union all
select 3 as kk ,'','','总合计', count(1) as '名',count(distinct 单据号) as '批',sum(c.费用), ''
from b, a,c
where b.单据号=a.单据号 and a.费用id = c.费用id
)
这样进行统计,也不能达到效果.那样统计后,合计全都到最后显示了. |
|