今天写了几个小时的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. Soufun_News

    using AnfleCrawler.Common; using System; using System.Collections.Generic; using System.ComponentMod ...

  2. Android webservice的用法详细讲解

    Android webservice的用法详细讲解 看到有很多朋友对WebService还不是很了解,在此就详细的讲讲WebService,争取说得明白吧.此文章采用的项目是我毕业设计的webserv ...

  3. android 拉伸图片

    Android拉伸图片用的是9.png格式的图片,这种图片可以指定图片的那一部分拉伸,那一部分显示内容,美工给的小图片也能有很好的显示效果. 原背景图片 可以看到原背景图片很小,即使在再长的文字,背景 ...

  4. springmvc学习第三天

    利用spring mvc 实现crud 1.导入jar包 commons-logging-1.2.jarjstl.jarspring-aop-4.1.6.RELEASE.jarspring-beans ...

  5. struts2 log4j:WARN Please initialize the log4j system properly. 解决方法

    在tomcat启动的时候,出现这个警告: log4j:WARN No appenders could be found for logger (org.apache.commons.digester. ...

  6. 加入Tomcat插件到ECLIPSE中的方法

    1.下载Tomcat插件com.sysdeo.eclipse.tomcat_3.3.1.jar 下载路径http://www.eclipsetotale.com/ 2.安装插件 把下载的插件放到E:\ ...

  7. Eos持久化实体

    持久化实体 2009-11-30 20:53:38|  分类: 记事本_学习笔记 |  标签: |举报 |字号大中小 订阅     在EOS的实体定义中,如果使用了关联实体方式,主实体的外键属性是不存 ...

  8. mybatis 注意问题

    <insert id="insertSelective" parameterType="com.hengxin.qianee.model.TalentUser&qu ...

  9. C++中的复制构造函数

    与C++中的构造函数相同,复制构造函数在对象生成过程中同样进行插入对应的Vtable虚表,但在成员变量赋值时,除具有复制构造函数的成员对象外,编译器合成复制构造函数其余均采用”Bitwise copy ...

  10. hdu 4336 Card Collector

    dp+状态压缩 #include<cstdio> using namespace std; ]; <<]; int main() { int n; while(scanf(&q ...