• 2016年11月26号随笔(关于oracle数据库)


    今天写了几个小时的sql语句,一开始我并没有思路,有思路便开始写。

    首先我查询了入库表中的3级单位下的各个网点的入库信息,找到这些信息后,我又去入库明细表中查询入库的详细信息

    找到了我要的把捆包箱的各个id

    select * from gzh_instock where outunitid
    in (select organizationid from cdms_organization start with
    organizationid='3862fa81-ac03-44de-8e82-d39dacce9c9d'
    connect by prior ORGANIZATIONID = PARENTID)

    //查询各个网点下的入库单的详细信息

    select * from gzh_instock_detail where billid
    in (select billid from gzh_instock where outunitid
    in (select organizationid from cdms_organization start with
    organizationid='3862fa81-ac03-44de-8e82-d39dacce9c9d'
    connect by prior ORGANIZATIONID = PARENTID))


    //把的残损和完整
    select ISDAMAGE,count(ISDAMAGE) from gzh_bainfo where barcode
    in (select barcode from gzh_instock_detail where billid
    in (select billid from gzh_instock where outunitid
    in (select organizationid from cdms_organization start with
    organizationid='3862fa81-ac03-44de-8e82-d39dacce9c9d'
    connect by prior ORGANIZATIONID = PARENTID))and to_char(billdate,'yyyy-MM')='2016-10' and UNIT='1') group by ISDAMAGE;
    //捆的残损和完整
    select ISDAMAGE,count(ISDAMAGE) from gzh_BunchInfo where bunchcode
    in (select barcode from gzh_instock_detail where billid
    in (select billid from gzh_instock where outunitid
    in (select organizationid from cdms_organization start with
    organizationid='3862fa81-ac03-44de-8e82-d39dacce9c9d'
    connect by prior ORGANIZATIONID = PARENTID)) and UNIT='2') group by ISDAMAGE;
    //箱的残损和完整
    select intactnum,damagenum from gzh_boxinfo where devcode
    in (select barcode from gzh_instock_detail where billid
    in (select billid from gzh_instock where outunitid
    in (select organizationid from cdms_organization start with
    organizationid='3862fa81-ac03-44de-8e82-d39dacce9c9d'
    connect by prior ORGANIZATIONID = PARENTID)) and UNIT='3');
    //包的残损和完整
    select intactnum,damagenum from gzh_pachetinfo where rfidno
    in (select barcode from gzh_instock_detail where billid
    in (select billid from gzh_instock where outunitid
    in (select organizationid from cdms_organization start with
    organizationid='3862fa81-ac03-44de-8e82-d39dacce9c9d'
    connect by prior ORGANIZATIONID = PARENTID)) and UNIT='4');
    select * from gzh_boxinfo;

    找到最后我要的数据后,我在我的逻辑层进行了数据的处理,得到我想要的结果。

    发现自己的sql写的很散,都是一块一块的没有结合起来,直接得到我要的结果集然后我开始构思

    尹哥给我的建议是从最深处的数据源开始找自己想要的代码,一步一步 的上移,得到自己想要的结果,我也是做了分析

    发现这个确实提高了我对数据库操作的效率,更快的得到了自己想要的结果。

  • 相关阅读:
    nextSibling VS nextElementSibling
    线程实现连续启动停,并在某一时间段内运行
    线程:安全终止与重启
    监控知识体系
    后台服务变慢解决方案
    Java泛型类型擦除以及类型擦除带来的问题
    常见的 CSRF、XSS、sql注入、DDOS流量攻击
    Spring对象类型——单例和多例
    一次线上OOM过程的排查
    深入浅出理解基于 Kafka 和 ZooKeeper 的分布式消息队列
  • 原文地址:https://www.cnblogs.com/sun1512/p/6102909.html
Copyright © 2020-2023  润新知