---电子凭证使用人次统计:
select xm as 姓名,sum(jzrc) as 总结算人次,sum(sfrc) as 电子凭证人次 from(
/收费结算人次/
select b.xm , count(distinct(a.sfsb)) jzrc,0 sfrc
from mz_mzsfk1 a, gy_zgxx b where --qudaodm=5
sfrq between to_date('2021/09/30','yyyy/mm/dd') and to_date ('2021-09-30 23:59:59','yyyy-mm-dd hh24:mi:ss')
and a.czgh=b.zgid
and brlb=-3
group by a.czgh, b.xm
union all
/电子凭证人次/
select b.xm, 0 jzrc ,sum(decode(nvl(a.zfgh,'none'),'none',1,-1)) sfrc
from mz_mzsfk1 a, gy_zgxx b where qudaodm=5
and sfrq between to_date('2021/09/30','yyyy/mm/dd') and to_date ('2021-09-30 23:59:59','yyyy-mm-dd hh24:mi:ss')
and a.czgh=b.zgid
group by a.czgh, b.xm )
group by xm
这段语句中添加一个限制条件:剔除年龄<14周岁的人,年龄(nl)这个字段在zj_jzxx c表,a表与这个表关联字段是a.brxm=c.brxm
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- qq_1306620048 2021-10-20 16:21关注
不知道是不是再给个意思 我改的我写备注了 希望对你有帮助
select xm as 姓名,sum(jzrc) as 总结算人次,sum(sfrc) as 电子凭证人次
from(
/收费结算人次/
select b.xm , count(distinct(a.sfsb)) jzrc,0 sfrc
from mz_mzsfk1 a, gy_zgxx b where --qudaodm=5
sfrq between to_date('2021/09/30','yyyy/mm/dd') and to_date ('2021-09-30 23:59:59','yyyy-mm-dd hh24:mi:ss')
and a.czgh=b.zgid
and brlb=-3
and a.brxm not in (select brxm from zj_jzxx where nl<14)//这里是我加的
group by a.czgh, b.xm
union all
/电子凭证人次/
select b.xm, 0 jzrc ,sum(decode(nvl(a.zfgh,'none'),'none',1,-1)) sfrc
from mz_mzsfk1 a, gy_zgxx b where qudaodm=5
and sfrq between to_date('2021/09/30','yyyy/mm/dd') and to_date ('2021-09-30 23:59:59','yyyy-mm-dd hh24:mi:ss')
and a.czgh=b.zgid
and a.brxm not in (select brxm from zj_jzxx where nl<14)//这里是我加的
group by a.czgh, b.xm)
group by xm本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 MATLAB代码补全插值
- ¥15 Typegoose 中如何使用 arrayFilters 筛选并更新深度嵌套的子文档数组信息
- ¥15 前后端分离的学习疑问?
- ¥15 stata实证代码答疑
- ¥50 husky+jaco2实现在gazebo与rviz中联合仿真
- ¥15 dpabi预处理报错:Error using y_ExtractROISignal (line 251)
- ¥15 在虚拟机中配置flume,无法将slave1节点的文件采集到master节点中
- ¥15 husky+kinova jaco2 仿真
- ¥15 zigbee终端设备入网失败
- ¥15 金融监管系统怎么对7+4机构进行监管的