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写的很散,都是一块一块的没有结合起来,直接得到我要的结果集然后我开始构思
尹哥给我的建议是从最深处的数据源开始找自己想要的代码,一步一步 的上移,得到自己想要的结果,我也是做了分析
发现这个确实提高了我对数据库操作的效率,更快的得到了自己想要的结果。
2016年11月26号随笔(关于oracle数据库)的更多相关文章
- 2016年11月26日 星期六 --出埃及记 Exodus 20:17
		2016年11月26日 星期六 --出埃及记 Exodus 20:17 "You shall not covet your neighbor's house. You shall not c ... 
- JuJu团队11月26号工作汇报
		JuJu团队11月26号工作汇报 JuJu Scrum 团队成员 今日工作 剩余任务 困难 于达 对原始文本进行预处理, 并转换成可被julia读入的格式 完成预处理并用julia读入. 读入后按 ... 
- 11月26号host
		127.0.0.1 localhost255.255.255.255 broadcasthost::1 localhostfe80::1%lo0 localhost # Google start216 ... 
- [日常]总结2016年7月入职至2016年7月26号微盘所遇bug
		2016年刚入职后在新浪微盘项目上所遇到的问题: 1.前端接口的程序不同版本问题,版本号在程序路径中区分,比如2.4.2/lib/sdk/api/weipan/Client.php 2.文件夹接口的m ... 
- [网站公告]11月26日00:00-04:00阿里云RDS升级
		大家好,11月26号00:00-04:00(今天夜里),阿里云将对我们所用的SQL Server RDS实例所在的物理主机做升级操作(目前博客园整站运行于阿里云上),升级期间RDS实例会有2次闪断,每 ... 
- 2016年11月ACM/ICPC亚洲区北京赛赛后总结
		2016年11月12到11月13为期两天的比赛,这是我们这个对第一次去打亚洲区域赛,经过这次比赛,我认识到了自己与别人的差距,也许我们与别人的起点不同,但这不是理由. 这次的比赛12号的热身赛两点开始 ... 
- struts2练习时犯的错误(2016年11月4日)
		1.Tomcat启动时报错 严重: 文档无效: 找不到语法. at (null:3:8) org.xml.sax.SAXParseException; systemId: file:/F:/Progr ... 
- MySQL_杭州11月1-29号在线产品在线天数、销售天数_20161129
		杭州11月1-29号在线产品在线天数.销售天数 1.产品在这个时间段内的每一天的在线情况,然后聚合计算每个产品的在线天数,每一天的在线情况 如果在线记为1,不在线为null 2.计算每个产品在这个时间 ... 
- psp进度(11月25号-31号)
		本周psp进度 11月25号 内容 开始时间 结束时间 打断时间 净时间 处理数据集 9:27 11:34 12m 115m 11月27号 内容 开始时间 结束时间 打断时间 净时间 scr ... 
随机推荐
- ffmepg-nginx-nginx-rtmp-module配置脚本
			把上个月写的的配置脚本贴一下: #!/bin/bash #version:-- #create by itn #dis: this is used to auto install ffmpeg+ngi ... 
- reverse-XNUCA-babyfuscator
			上一次线上赛的一道题目 链接:http://pan.baidu.com/s/1qY9ztKC 密码:xlr2 这是一道代码混淆的题目,因为当时还不知道angr这样一个软件,所以我就用了自己的一种思路 ... 
- 电子词典的相关子函数db.c程序
			整个电子词典是分块做的:包含的Dic_Server.c,Dic_Client.c,db.c,query.c,xprtcl.c,dict.h,xprtcl.h,dict.txt(单词文件) 下面是db. ... 
- JQuery正则验证
			比较常用的: function checkIshanzi(s) { //var patrn = /^[\u2E80-\u9FFF]$/; //Unicode编码中的汉字范围 /[^\x00-\x80] ... 
- jquery ajax error函数详解
			代码:$(document).ready(function() { jQuery("#clearCac").click(function() { ... 
- sqlite3使用(一)
			最近工作接触到sqlite3了,于是用博客记录下,当然只是浅用哈! 参考资料:http://www.runoob.com/sqlite/sqlite-tutorial.html 概念: SQLite ... 
- sscanf格式化输出
			char DesChar[20] = {0}; char* SouChar= "1cZCD23456abEFdedfB"; sscanf(SouChar,"%[^A-Z] ... 
- Linux设计准则
			计算机体系结构: 运算器 控制器 存储器,内存,编址 输出设备 输入设备 Linux内核功能: 进程管理内存管理文件系统网络功能硬件驱动安全机制 Linux的基本原则: 1.由目的单一的小程序组成: ... 
- 九度oj  题目1087:约数的个数
			题目链接:http://ac.jobdu.com/problem.php?pid=1087 题目描述: 输入n个整数,依次输出每个数的约数的个数 输入: 输入的第一行为N,即数组的个数(N<=1 ... 
- Validation failed for one or more entities. See ‘EntityValidationErrors’解决方法【转载】
			摘自:http://www.cnblogs.com/douqiumiao/default.aspx?opt=msg Validation failed for one or more entities ... 
