send one complex porblem on 'sql ' to our friends ,come here plese,baby,baby!! 可以不用union:select cphm, sum(decode(yllx,'汽油',jyl,0)) as jyl, sum(decode(yllx,'汽油',jyl,0)), sum(decode(yllx,'机油',jyl,0)) from agroup by cphm 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 walkworm,哥们,多谢参与,但是我的确没分,要不是还有这一分,我连问题都问不了 呵呵,没事,我说笑呢。。不然我也不会回答了。。再多说一句,要是用union的话就要分两步了,得建一个中间的view,不如用decode方便。。 walkworm,您好,请问您能给小弟解释一下select cphm, sum(decode(yllx,'汽油',jyl,0)) as jyl, sum(decode(yllx,'汽油',jyl,0)), sum(decode(yllx,'机油',jyl,0)) 是身摸意思?decode 的含义? decode的用法:decode(要比较的表达式 ,条件1 ,当表达式的值等于条件1时返回的值 ,条件2 ,当表达式的值等于条件2时返回的值 , ... , 当表达式不等于列表中任何一值时返回的值) 没有错啊,只是我第一次写多了一列,重新给一次:select cphm, sum(decode(yllx,'汽油',jyl,0)) as jyl,sum(decode(yllx,'机油',jyl,0)) as jy_jyl from a group by cphm jobs 手动运行可以 自动运行就会报错、断开。怎么解决啊! Oracle ERP表复合索引的使用 oracle 根据某列值 统计个数[数据统计表页面SQL] oracle 连接 很慢 关于索引失效问题 有没有必要建立两个数据库 那里有ORACLE下载啊 oracle开发过程总遇到的问题 菜鸟问题,如何使用触发器? 什么语句能把一个表中的所有字段名列出来? 从DBA Studio、SQLPlus和SQLPLUS WORKSHEET对表的操作结果为什么不同? 请教,在Oracle中的sql问题!
不然我也不会回答了。。再多说一句,要是用union的话就要分两步了,得建一个中间的view,不如用decode方便。。
select cphm, sum(decode(yllx,'汽油',jyl,0)) as jyl, sum(decode(yllx,'汽油',jyl,0)), sum(decode(yllx,'机油',jyl,0))
是身摸意思?
decode 的含义?
select cphm, sum(decode(yllx,'汽油',jyl,0)) as jyl,sum(decode(yllx,'机油',jyl,0)) as jy_jyl
from a group by cphm