求一个简单的分组!!当费用聚合为空的时候,照样把费用为空的显示出来!!谢谢

iceflylee 2005-03-18 09:58:36
费用1 费用2 费用3
人员1
人员2
人员3
...全文
73 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
yxxx 2005-03-18
  • 打赏
  • 举报
回复
select person,
nvl(sum(decode(fee,'费用1',total)),0)费用1,
nvl(sum(decode(fee,'费用2',total)),0)费用2,
nvl(sum(decode(fee,'费用3',total)),0)费用3
from table
group by person;
dybinchn 2005-03-18
  • 打赏
  • 举报
回复
SELECT SUM(NVL(费用1,0)),SUM(NVL(费用2,0)),SUM(NVL(费用3,0))
FROM TBL
GROUP BY 人员
iceflylee 2005-03-18
  • 打赏
  • 举报
回复
不够
iceflylee 2005-03-18
  • 打赏
  • 举报
回复
人员,费用,合计。怎么分组完变成
费用1 费用2 费用3
人员1
人员2
人员3

yxxx 2005-03-18
  • 打赏
  • 举报
回复
nvl()够不够?
zninger 2005-03-18
  • 打赏
  • 举报
回复
只要判断就可以了
select case when 费用1 is null then 0 end 费用1,
case when 费用2 is null then 0 end 费用2,
case when 费用3 is null then 0 end 费用3
from 表名
yxxx 2005-03-18
  • 打赏
  • 举报
回复
能详细一点吗?
zninger 2005-03-18
  • 打赏
  • 举报
回复
只要判断就可以了
select case when 费用1 is null then 0 end 费用1,
case when 费用2 is null then 0 end 费用2,
case when 费用3 is null then 0 end 费用4,
from 表名
iceflylee 2005-03-18
  • 打赏
  • 举报
回复
一天内结贴

17,140

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧