oracle如何统计一行数据和

筱妺 2014-06-16 04:33:50

select app_work_type,
sum(case
when app_level = '0' then
1
else
0
end) as a,
sum(case
when app_level = '1' then
1
else
0
end) as b,
sum(case
when app_level = '2' then
1
else
0
end) as c,
sum(case
when app_level = '3' then
1
else
0
end) as d,
sum(a+b+c+d)as total
from t_authenticate_reg
group by app_work_type;
为什么会有标识符无效,就是那个‘d’
...全文
232 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
筱妺 2014-06-16
  • 打赏
  • 举报
回复
那要怎么改呀,我才接触Oracle,请您指教一下,好吗?
CT_LXL 2014-06-16
  • 打赏
  • 举报
回复
引用 楼主 YXyangxian 的回复:
select app_work_type, sum(case when app_level = '0' then 1 else 0 end) as a, sum(case when app_level = '1' then 1 else 0 end) as b, sum(case when app_level = '2' then 1 else 0 end) as c, sum(case when app_level = '3' then 1 else 0 end) as d, sum(a+b+c+d)as total from t_authenticate_reg group by app_work_type; 为什么会有标识符无效,就是那个‘d’
在同一层次里,不能用别名

17,089

社区成员

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

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