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 oracle小問題 一个oracle建表问题 oracle多表关联删除oracle如何确定删除哪张表的数据? SQL 的WHERE条件怎么写 谁帮忙解决一下ORACLE语句 如何在trigger 中执行动态sql VC怎么通过oo4o中导入日期类型数据? 怎样将Oracle中的数据导出为sql脚本,急~~ ==多用户操作的问题?==== 急,急,怎样在proc中应用动态方法4调用存储过程 从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