凡是这种问题不可用group by !
解决方案 »
- 请问如何重绘VB6中的StatusBar控件
- 关于XML的编程
- 高手请教!如何实现Sendkeys
- 请教一个ADO的问题。
- 一只兔子在公司的遭遇 --
- 请问大家谁知道文档,图片,多媒体文件怎么可以从sql数据库中显示在vb中阿,用什么控件在vb中显示阿
- lihonggen0(李洪根,用.NET,标准答案来了),你的联系方式多少?
- 求救!关于在vb程序中sqlserver数据库的连接!
- 用这个选择 picture1内裁剪后的图形,该用哪个API移动到picture2内呢?
- 感谢 1come(白开水)的代码,送分 120之三(我只能给30)
- 请问:班主平时都做点什么?
- VB中如果不用数据环境设计器,如何直接调用存储过程?
where table1.科目='办公用品') as 办公费
,(select sum(借方) from 资金明细表 table2
where table2.科目='车费') as 车费
.......
,(select sum(借方) from 资金明细表 tableN) as 总费用
,(select sum(借方) from 资金明细表 tableN1
where tableN1.科目<>'车费' and ...<>'办公用品’ ....)as 其他费用
when 科目 in ('办公用品','车费','饭补','评审费','会议费')
then 科目
else '其他费用'
end,
sum(借方) as 科目统计
from 资金明细表
group by case
when 科目 in ('办公用品','车费','饭补','评审费','会议费')
then 科目
else '其他费用'
end
select 科目,sum(借方) as 科目统计 from 资金明细表
where 科目='办公用品' or 科目='车费' or 科目='饭补' or 科目='评审费' or 科目='会议费' group by 科目
union
select '其它费用' as 科目,sum(借方) as 科目统计 from 资金明细表 where
(科目<>'办公用品' and 科目<>'车费' and 科目='饭补' and 科目='评审费' and 科目='会议费')
union
select '总费用' as 科目,sum(借方) as 科目统计 from 资金明细表
也可以这样:select case
when 科目 in ('办公用品','车费','饭补','评审费','会议费')
then 科目
else '其他费用'
end,
sum(借方) as 科目统计
from 资金明细表
group by case
when 科目 in ('办公用品','车费','饭补','评审费','会议费')
then 科目
else '其他费用'
end
union
select '总费用' as 科目,sum(借方) as 科目统计 from 资金明细表
自己试吧,实在没时间了