m0_63211059 2021-10-20 16:10 采纳率: 100%
浏览 35
已结题

这段语句中添加一个限制条件:剔除年龄<14周岁的人,年龄(nl)这个字段在zj_jzxx c表,a表与这个表关联字段是a.brxm=c.brxm

---电子凭证使用人次统计:
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

  • 写回答

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 10月28日
  • 已采纳回答 10月20日
  • 创建了问题 10月20日

悬赏问题

  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)