select
sum(实时话费),count(*) from (
select a.user_id,
sum(case when a.kind='zdjm' then a.je else 0 end) 帐单减免,
sum(case when a.kind='hbkz' then a.je else 0 end) 划拨扣帐,
sum(case when a.kind='shqf' then a.je else 0 end) 收回欠费,
/*sum(case when a.kind='zhyc' then a.je else 0 end) 帐户级预存,
sum(case when a.kind='yhyc' then a.je else 0 end) 用户级预存,*/
sum(case when a.kind='sshf' then a.je else 0 end) 实时话费,
sum(case when a.kind='gchf' then a.je else 0 end) 估测话费,
sum(case when a.kind='tcdx' then a.je else 0 end) 套餐低消,
sum(case when a.kind='yhdx' then a.je else 0 end) 用户低消,
sum(case when a.kind='yhzjdq' then a.je else 0 end) 用户租机到期,
sum(case when a.kind='zhzjdq' then a.je else 0 end) 帐户租机到期,
sum(case when a.kind='yhzhdx' then a.je else 0 end) 用户帐户低消,
sum(case when a.kind='zhdx' then a.je else 0 end) 帐户低消,
sum(case when a.kind='tf' then a.je else 0 end) 退费
from dsz_kzyc_new a
group by a.user_id having sum(case when a.kind='sshf' then a.je else 0 end)<>0)这个脚本为什么注释两行跟不注释结果不一样。谢谢
sum(实时话费),count(*) from (
select a.user_id,
sum(case when a.kind='zdjm' then a.je else 0 end) 帐单减免,
sum(case when a.kind='hbkz' then a.je else 0 end) 划拨扣帐,
sum(case when a.kind='shqf' then a.je else 0 end) 收回欠费,
/*sum(case when a.kind='zhyc' then a.je else 0 end) 帐户级预存,
sum(case when a.kind='yhyc' then a.je else 0 end) 用户级预存,*/
sum(case when a.kind='sshf' then a.je else 0 end) 实时话费,
sum(case when a.kind='gchf' then a.je else 0 end) 估测话费,
sum(case when a.kind='tcdx' then a.je else 0 end) 套餐低消,
sum(case when a.kind='yhdx' then a.je else 0 end) 用户低消,
sum(case when a.kind='yhzjdq' then a.je else 0 end) 用户租机到期,
sum(case when a.kind='zhzjdq' then a.je else 0 end) 帐户租机到期,
sum(case when a.kind='yhzhdx' then a.je else 0 end) 用户帐户低消,
sum(case when a.kind='zhdx' then a.je else 0 end) 帐户低消,
sum(case when a.kind='tf' then a.je else 0 end) 退费
from dsz_kzyc_new a
group by a.user_id having sum(case when a.kind='sshf' then a.je else 0 end)<>0)这个脚本为什么注释两行跟不注释结果不一样。谢谢
解决方案 »
- 现有服务器8G内存,如何优化oracle的参数
- 為何用sum匯總前後數據不一致
- 有个IMP问题 请教大家~
- pl sql 小查询,路过的不要错过了
- Oracle8i和Oracle8.05有什么区别?
- 请教PowerDesign中是否能自动生成数据库系统设计的数据字典
- 一张表中分别建多个索引与建一个包含多个字段的索引,哪种性能优?为什么?
- 求助一下错误原因,oracle输入代码后就出现如下错误
- JAVA BEAN有个属性long类型,oracle表中对应的字段也是long类型,但是HQL查询出来放在list里出错,应该怎么处理这个字段的问题?
- 关于Oracle 11g维修窗口?请大神详解?
- 新人求解,这个语句如何修改
- 数据库(块-区-段-表)
COUNT returns the number of rows returned by the query. You can use it as an aggregate or analytic function.If you specify DISTINCT, then you can specify only the query_partition_clause of the analytic_clause. The order_by_clause and windowing_clause are not allowed.If you specify expr, then COUNT returns the number of rows where expr is not null. You can count either all rows, or only distinct values of expr.If you specify the asterisk (*), then this function returns all rows, including duplicates and nulls. COUNT never returns null.Maybe return 0.
那2个类型的条数是不是 411820 - 406764 ?里面计算的行数 只是包涵里面列出kind=这些字符串的行数 没列出来的其他字符串自然不计算在里面了