博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
用碑情况统计
阅读量:6788 次
发布时间:2019-06-26

本文共 3131 字,大约阅读时间需要 10 分钟。

INSERT INTO BUSINESS_EX_INFOSELECT SEQ_BUSINESSEXINFO_ID.NEXTVAL,ID,16,'是' FROM qtywb where (ywdm='12' OR YWDM='14') and zxflag<>'1';--用碑数据--SELECT ssrq, mx,sum(zys) as zys,sum(jgs) as jgs,sum(BQTWYBS) as BQTWYBS,sum(BQTYYBS) as BQTYYBS,sum(BQTMS) as BQTMS,sum(FBQTWYBS) as FBQTWYBS,sum(FBQTYYBS) as FBQTYYBS,sum(FBQTMS) as FBQTMS FROM (--租用--SELECT TO_CHAR(rq,'yyyymm') as ssrq,mxmc as mx,count(*) AS ZYS,0 AS JGS,0 AS BQTWYBS,0 AS BQTYYBS,0 AS BQTMS,0 AS FBQTWYBS,0 AS FBQTYYBS,0 AS FBQTMS FROM ywdjb WHERE zxflag<>'1' AND to_char(rq,'yyyy-mm-dd')>='1900-05-26' AND to_char(rq,'yyyy-mm-dd')<='2016-06-30' GROUP BY mxmc,TO_CHAR(rq,'yyyymm')UNION ALL--旧墓改造--SELECT TO_CHAR(rq,'yyyymm') as ssrq,mxmc as mx,0,count(*),0,0,0,0,0,0 FROM qtywb WHERE zxflag<>'1' AND ywdm='14' AND to_char(rq,'yyyy-mm-dd')>='1900-05-26' AND to_char(rq,'yyyy-mm-dd')<='2016-06-30' GROUP BY mxmc,TO_CHAR(rq,'yyyymm')UNION ALL--本期退--SELECT TO_CHAR(rq,'yyyymm') as ssrq,mxmc as mx,0,0,0,0,count(*),0,0,0 FROM qtywb t1 WHERE zxflag<>'1' AND ywdm='12' AND djh IN(SELECT djh FROM ywdjb WHERE t1.djh=djh and to_char(rq,'yyyy-mm-dd')>='1900-05-26' AND to_char(rq,'yyyy-mm-dd')<='2016-06-30') GROUP BY mxmc,TO_CHAR(rq,'yyyymm')UNION ALL--非本期退--SELECT TO_CHAR(rq,'yyyymm') as ssrq,mxmc as mx,0,0,0,0,0,0,0,count(*) FROM qtywb t1 WHERE zxflag<>'1' AND ywdm='12' AND djh NOT IN(SELECT djh FROM ywdjb WHERE t1.djh=djh and to_char(rq,'yyyy-mm-dd')>='1900-05-26' AND to_char(rq,'yyyy-mm-dd')<='2016-06-30') GROUP BY mxmc,TO_CHAR(rq,'yyyymm')UNION ALL--本期退未用碑数--SELECT TO_CHAR(rq,'yyyymm') as ssrq,mxmc as mx,0,0,count(*),0,0,0,0,0 FROM qtywb t1,BUSINESS_EX_INFO t2 WHERE t1.zxflag<>'1' AND t1.ywdm='12' and t2.BUSINESS_ID=t1.id and PROPERTY_ID=16 and PROPERTY_VALUE='否' AND DJH IN(SELECT djh FROM ywdjb WHERE t1.djh=djh and to_char(rq,'yyyy-mm-dd')>='1900-05-26' AND to_char(rq,'yyyy-mm-dd')<='2016-06-30') GROUP BY mxmc,TO_CHAR(rq,'yyyymm')UNION ALL--本期退已用碑数--SELECT TO_CHAR(rq,'yyyymm') as ssrq,mxmc as mx,0,count(*),0,0,0,0,0,0 FROM qtywb t1,BUSINESS_EX_INFO t2 WHERE t1.zxflag<>'1' AND t1.ywdm='12' and t2.BUSINESS_ID=t1.id and PROPERTY_ID=16 and PROPERTY_VALUE='是' AND DJH IN(SELECT djh FROM ywdjb WHERE t1.djh=djh and to_char(rq,'yyyy-mm-dd')>='1900-05-26' AND to_char(rq,'yyyy-mm-dd')<='2016-06-30') GROUP BY mxmc,TO_CHAR(rq,'yyyymm')UNION ALL--非本期退未用碑数--SELECT TO_CHAR(rq,'yyyymm') as ssrq,mxmc as mx,0,0,0,0,0,count(*),0,0 FROM qtywb t1,BUSINESS_EX_INFO t2 WHERE t1.zxflag<>'1' AND t1.ywdm='12' and t2.BUSINESS_ID=t1.id and PROPERTY_ID=16 and PROPERTY_VALUE='否' AND DJH NOT IN(SELECT djh FROM ywdjb WHERE t1.djh=djh and to_char(rq,'yyyy-mm-dd')>='1900-05-26' AND to_char(rq,'yyyy-mm-dd')<='2016-06-30') GROUP BY mxmc,TO_CHAR(rq,'yyyymm')UNION ALL--非本期退已用碑数--SELECT TO_CHAR(rq,'yyyymm') as ssrq,mxmc as mx,0,0,0,0,0,0,count(*),0 FROM qtywb t1,BUSINESS_EX_INFO t2 WHERE t1.zxflag<>'1' AND t1.ywdm='12' and t2.BUSINESS_ID=t1.id and PROPERTY_ID=16 and PROPERTY_VALUE='是' AND DJH NOT IN(SELECT djh FROM ywdjb WHERE t1.djh=djh and to_char(rq,'yyyy-mm-dd')>='1900-05-26' AND to_char(rq,'yyyy-mm-dd')<='2016-06-30') GROUP BY mxmc,TO_CHAR(rq,'yyyymm')) group by mx,ssrq;

 

转载地址:http://gjbgo.baihongyu.com/

你可能感兴趣的文章
学习phalcon开发笔记
查看>>
vlan规划方案
查看>>
java参数传递(超经典)
查看>>
IMAP和POP3区别
查看>>
快速安装php php-fpm nignx
查看>>
ubuntu日常使用心得(随时更新中。。。)
查看>>
Java 多线程回顾
查看>>
第14章 使用DHCP动态管理主机地址
查看>>
二、nginx服务器基础配置命令
查看>>
TEMP表空间之Ogg复制进程占用
查看>>
java中的构造函数总结
查看>>
windows下kangle虚拟主机-安装mysql教程及心得
查看>>
我的友情链接
查看>>
ios中SQLite的重构封装
查看>>
centos 搭建 nagios 监控系统.
查看>>
Nginx 生成公钥和私钥
查看>>
管理禁忌小记录(一)
查看>>
遍历接口信息
查看>>
Dell R710 服务器更新windows server 2012的相关问题
查看>>
完美解决 java.lang.NoClassDefFoundError R$layout R$di
查看>>