今天写了几个小时的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写的很散,都是一块一块的没有结合起来,直接得到我要的结果集然后我开始构思

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

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

2016年11月26号随笔(关于oracle数据库)的更多相关文章

  1. 2016年11月26日 星期六 --出埃及记 Exodus 20:17

    2016年11月26日 星期六 --出埃及记 Exodus 20:17 "You shall not covet your neighbor's house. You shall not c ...

  2. JuJu团队11月26号工作汇报

    JuJu团队11月26号工作汇报 JuJu   Scrum 团队成员 今日工作 剩余任务 困难 于达 对原始文本进行预处理, 并转换成可被julia读入的格式 完成预处理并用julia读入. 读入后按 ...

  3. 11月26号host

    127.0.0.1 localhost255.255.255.255 broadcasthost::1 localhostfe80::1%lo0 localhost # Google start216 ...

  4. [日常]总结2016年7月入职至2016年7月26号微盘所遇bug

    2016年刚入职后在新浪微盘项目上所遇到的问题: 1.前端接口的程序不同版本问题,版本号在程序路径中区分,比如2.4.2/lib/sdk/api/weipan/Client.php 2.文件夹接口的m ...

  5. [网站公告]11月26日00:00-04:00阿里云RDS升级

    大家好,11月26号00:00-04:00(今天夜里),阿里云将对我们所用的SQL Server RDS实例所在的物理主机做升级操作(目前博客园整站运行于阿里云上),升级期间RDS实例会有2次闪断,每 ...

  6. 2016年11月ACM/ICPC亚洲区北京赛赛后总结

    2016年11月12到11月13为期两天的比赛,这是我们这个对第一次去打亚洲区域赛,经过这次比赛,我认识到了自己与别人的差距,也许我们与别人的起点不同,但这不是理由. 这次的比赛12号的热身赛两点开始 ...

  7. struts2练习时犯的错误(2016年11月4日)

    1.Tomcat启动时报错 严重: 文档无效: 找不到语法. at (null:3:8) org.xml.sax.SAXParseException; systemId: file:/F:/Progr ...

  8. MySQL_杭州11月1-29号在线产品在线天数、销售天数_20161129

    杭州11月1-29号在线产品在线天数.销售天数 1.产品在这个时间段内的每一天的在线情况,然后聚合计算每个产品的在线天数,每一天的在线情况 如果在线记为1,不在线为null 2.计算每个产品在这个时间 ...

  9. psp进度(11月25号-31号)

    本周psp进度 11月25号 内容 开始时间 结束时间 打断时间 净时间 处理数据集  9:27  11:34  12m  115m 11月27号 内容 开始时间 结束时间 打断时间 净时间  scr ...

随机推荐

  1. 2014年5月份第3周51Aspx源码发布详情

    HGM简单连连看游戏源码  2014-5-19 [VS2010]源码描述:这是一款基于WinForm窗体程序的简单水果连连看的小游戏.界面比较美观, 功能如下:该游戏可以显示当前关卡,还有剩余时间.重 ...

  2. JS rem 设置

    (function () { var docEl = document.documentElement; var resize = 'orientationchange' in window ? 'o ...

  3. (转)android平台phonegap框架实现原理

    (原文)http://blog.csdn.net/wuruixn/article/details/7405175 android平台phonegap框架实现原理 分类: Android2012-03- ...

  4. Oracle帮助类

    /// <summary> /// Copyright (C) Maticsoft /// 数据访问基础类(基于Oracle) /// 可以用户可以修改满足自己项目的需要. /// < ...

  5. SVN 文件解锁

    之前一直一个人用svn,后来团队扩编,同事使用svn下载项目后.我却无法提交了,出现以下错误: locked in another working copy No lock on path (Stat ...

  6. logback配置错误邮件发送

    配置logback发送error级别日志到指定邮箱 需要导入jar包:janino.jar <property name="smtpHost" value="smt ...

  7. HDU 4777 Rabbit Kingdom (2013杭州赛区1008题,预处理,树状数组)

    Rabbit Kingdom Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  8. jdbc 配置

    jdbc 配置 Class.forName("com.mysql.jdbc.Driver")  ;//加载数据库驱动 Connection conn=null; String ur ...

  9. jquery模板制作左侧导航组件

    /** * Created by bmk on 16-4-25. * * 用法:在自己的js里面把左侧导航的相关图标和对应的列表项名称如下编写: * 版本更新日至按需添加 * 在js中的RNA.run ...

  10. JQUERY知识总结

    1, 让页面上某一个已存在的SELECT被选中的JQuery写法  $("#test").find("option[value='3']").prop(&quo ...