本人本月等超载率的sql:
本日:select t1.countycode,t1.count1 as allnumber,nvl(t2.count2,0) as overnumber,nvl(to_char(t2.count2/t1.count1*100,'990.00'),0) as overpercent from (select t.countycode as countycode,count(*) as count1 from t_checkinfo t where ( t.countycode='140603' or t.countycode='140623' or t.countycode='140602' or t.countycode='140624' or t.countycode='140600' or t.countycode='140622' or t.countycode='140621' ) and trunc(t.checkdate)=trunc(sysdate) group by t.countycode) t1 left outer join (select t.countycode ,count(*) as count2 from t_checkinfo t where ( t.countycode='140603' or t.countycode='140623' or t.countycode='140602' or t.countycode='140624' or t.countycode='140600' or t.countycode='140622' or t.countycode='140621' ) and t.ispunished!=0 and trunc(t.checkdate)=trunc(sysdate) group by t.countycode) t2 on t1.countycode=t2.countycode
本周:select t1.countycode,t1.count1 as allnumber,nvl(t2.count2,0) as overnumber,nvl(to_char(t2.count2/t1.count1*100,'990.00'),0) as overpercent from (select t.countycode as countycode,count(*) as count1 from t_checkinfo t where ( t.countycode='140603' or t.countycode='140623' or t.countycode='140602' or t.countycode='140624' or t.countycode='140600' or t.countycode='140622' or t.countycode='140621' ) and t.checkdate >=(trunc(sysdate, 'd') + 1) and t.checkdate<=( trunc(sysdate, 'd') + 8) group by t.countycode) t1 left outer join (select t.countycode ,count(*) as count2 from t_checkinfo t where ( t.countycode='140603' or t.countycode='140623' or t.countycode='140602' or t.countycode='140624' or t.countycode='140600' or t.countycode='140622' or t.countycode='140621' ) and t.ispunished!=0 and t.checkdate >=(trunc(sysdate, 'd') + 1) and t.checkdate<=( trunc(sysdate, 'd') + 8) group by t.countycode) t2 on t1.countycode=t2.countycode
本月:select t1.countycode,t1.count1 as allnumber,nvl(t2.count2,0) as overnumber,nvl(to_char(t2.count2/t1.count1*100,'990.00'),0) as overpercent from (select t.countycode as countycode,count(*) as count1 from t_checkinfo t where ( t.countycode='140603' or t.countycode='140623' or t.countycode='140602' or t.countycode='140624' or t.countycode='140600' or t.countycode='140622' or t.countycode='140621' ) and t.checkdate >=(trunc(sysdate, 'mm')) and t.checkdate<=last_day(trunc(sysdate)) group by t.countycode) t1 left outer join (select t.countycode ,count(*) as count2 from t_checkinfo t where ( t.countycode='140603' or t.countycode='140623' or t.countycode='140602' or t.countycode='140624' or t.countycode='140600' or t.countycode='140622' or t.countycode='140621' ) and t.ispunished!=0 and t.checkdate >=(trunc(sysdate, 'mm')) and t.checkdate<=last_day(trunc(sysdate)) group by t.countycode) t2 on t1.countycode=t2.countycode
本季:select t1.countycode,t1.count1 as allnumber,nvl(t2.count2,0) as overnumber,nvl(to_char(t2.count2/t1.count1*100,'990.00'),0) as overpercent from (select t.countycode as countycode,count(*) as count1 from t_checkinfo t where ( t.countycode='140603' or t.countycode='140623' or t.countycode='140602' or t.countycode='140624' or t.countycode='140600' or t.countycode='140622' or t.countycode='140621' ) and t.checkdate >=(trunc(sysdate, 'Q')) and t.checkdate<=(add_months(trunc(sysdate, 'Q'), 3) - 1) group by t.countycode) t1 left outer join (select t.countycode ,count(*) as count2 from t_checkinfo t where ( t.countycode='140603' or t.countycode='140623' or t.countycode='140602' or t.countycode='140624' or t.countycode='140600' or t.countycode='140622' or t.countycode='140621' ) and t.ispunished!=0 and t.checkdate >=(trunc(sysdate, 'Q')) and t.checkdate<=(add_months(trunc(sysdate, 'Q'), 3) - 1) group by t.countycode) t2 on t1.countycode=t2.countycode
本年:select t1.countycode,t1.count1 as allnumber,nvl(t2.count2,0) as overnumber,nvl(to_char(t2.count2/t1.count1*100,'990.00'),0) as overpercent from (select t.countycode as countycode,count(*) as count1 from t_checkinfo t where ( t.countycode='140603' or t.countycode='140623' or t.countycode='140602' or t.countycode='140624' or t.countycode='140600' or t.countycode='140622' or t.countycode='140621' ) and t.checkdate >=trunc(sysdate, 'yyyy') and t.checkdate<=(add_months(trunc(sysdate, 'yyyy'), 12) - 1) group by t.countycode) t1 left outer join (select t.countycode ,count(*) as count2 from t_checkinfo t where ( t.countycode='140603' or t.countycode='140623' or t.countycode='140602' or t.countycode='140624' or t.countycode='140600' or t.countycode='140622' or t.countycode='140621' ) and t.ispunished!=0 and t.checkdate >=trunc(sysdate, 'yyyy') and t.checkdate<=(add_months(trunc(sysdate, 'yyyy'), 12) - 1) group by t.countycode) t2 on t1.countycode=t2.countycode
----------------------------------------------------------------------------------
统计分析sql:
1. 天统计:
所有统计:
select t1.sitecode as sitecode,t1.sitename as sitename,to_char(t1.dateperiod,'yyyy-mm-dd') as dateperiod ,t1.allnum as allnumber,nvl(t2.overnum,0) as overnumber,nvl(to_char(t2.overnum/t1.allnum*100,'990.00'),0) as overpercent from (select t.sitecode as sitecode,t.sitename as sitename,trunc(t.checkdate,'dd') as datePeriod,count(*) as allnum from t_checkinfo t where t.checkdate between to_date('2013-12-27','yyyy-mm-dd') and to_date('2014-01-03','yyyy-mm-dd') group by t.sitecode,t.sitename,trunc(t.checkdate,'dd') ) t1 left outer join (select t.sitecode as sitecode,t.sitename as sitename,trunc(t.checkdate,'dd') as datePeriod,count(*) as overnum from t_checkinfo t where t.checkdate between to_date('2013-12-27','yyyy-mm-dd') and to_date('2014-01-03','yyyy-mm-dd') and t.ifoverload=2 group by t.sitecode,t.sitename ,trunc(t.checkdate,'dd') ) t2 on t1.sitecode=t2.sitecode and t1.sitename=t2.sitename and t1.dateperiod=t2.dateperiod order by sitecode ,dateperiod desc
2.周统计:
所有的统计:
select t1.sitecode as sitecode,t1.sitename as sitename,t1.dateperiod as dateperiod ,t1.allnum as allnumber,nvl(t2.overnum,0) as overnumber,nvl(to_char(t2.overnum/t1.allnum*100,'990.00'),0) as overpercent from (select t.sitecode as sitecode,t.sitename as sitename,to_char(t.checkdate,'iw') as datePeriod,count(*) as allnum from t_checkinfo t where t.checkdate between to_date('2013-12-1','yyyy-mm-dd') and to_date('2014-1-1','yyyy-mm-dd') group by t.sitecode,t.sitename,to_char(t.checkdate,'iw') ) t1 left outer join (select t.sitecode as sitecode,t.sitename as sitename,to_char(t.checkdate,'iw') as datePeriod,count(*) as overnum from t_checkinfo t where t.checkdate between to_date('2013-12-1','yyyy-mm-dd') and to_date('2014-1-1','yyyy-mm-dd') and t.ifoverload=2 group by t.sitecode,t.sitename ,to_char(t.checkdate,'iw') ) t2 on t1.sitecode=t2.sitecode and t1.sitename=t2.sitename and t1.dateperiod=t2.dateperiod order by sitecode ,dateperiod desc
某个区县的统计:
select t1.sitecode as sitecode,t1.sitename as sitename,t1.dateperiod as dateperiod ,t1.allnum as allnumber,nvl(t2.overnum,0) as overnumber,nvl(to_char(t2.overnum/t1.allnum*100,'990.00'),0) as overpercent from (select t.sitecode as sitecode,t.sitename as sitename,to_char(t.checkdate,'iw') as datePeriod,count(*) as allnum from t_checkinfo t where t.checkdate between to_date('2013-12-1','yyyy-mm-dd') and to_date('2014-1-1','yyyy-mm-dd') and t.countycode='140602' group by t.sitecode,t.sitename,to_char(t.checkdate,'iw') ) t1 left outer join (select t.sitecode as sitecode,t.sitename as sitename,to_char(t.checkdate,'iw') as datePeriod,count(*) as overnum from t_checkinfo t where t.checkdate between to_date('2013-12-1','yyyy-mm-dd') and to_date('2014-1-1','yyyy-mm-dd') and t.countycode='140602' and t.ifoverload=2 group by t.sitecode,t.sitename ,to_char(t.checkdate,'iw') ) t2 on t1.sitecode=t2.sitecode and t1.sitename=t2.sitename and t1.dateperiod=t2.dateperiod order by sitecode ,dateperiod desc
某个站点的统计:
select t1.sitecode as sitecode,t1.sitename as sitename,t1.dateperiod as dateperiod ,t1.allnum as allnumber,nvl(t2.overnum,0) as overnumber,nvl(to_char(t2.overnum/t1.allnum*100,'990.00'),0) as overpercent from (select t.sitecode as sitecode,t.sitename as sitename,to_char(t.checkdate,'iw') as datePeriod,count(*) as allnum from t_checkinfo t where t.checkdate between to_date('2013-12-1','yyyy-mm-dd') and to_date('2014-1-1','yyyy-mm-dd') and t.sitecode='1406021001' group by t.sitecode,t.sitename,to_char(t.checkdate,'iw') ) t1 left outer join (select t.sitecode as sitecode,t.sitename as sitename,to_char(t.checkdate,'iw') as datePeriod,count(*) as overnum from t_checkinfo t where t.checkdate between to_date('2013-12-1','yyyy-mm-dd') and to_date('2014-1-1','yyyy-mm-dd') and t.sitecode='1406021001' and t.ifoverload=2 group by t.sitecode,t.sitename ,to_char(t.checkdate,'iw') ) t2 on t1.sitecode=t2.sitecode and t1.sitename=t2.sitename and t1.dateperiod=t2.dateperiod order by sitecode ,dateperiod desc
3. 月统计,所有:
select t1.sitecode as sitecode,t1.sitename as sitename,t1.dateperiod as dateperiod ,t1.allnum as allnumber,nvl(t2.overnum,0) as overnumber,nvl(to_char(t2.overnum/t1.allnum*100,'990.00'),0) as overpercent from (select t.sitecode as sitecode,t.sitename as sitename,to_char(t.checkdate,'mm') as datePeriod,count(*) as allnum from t_checkinfo t where t.checkdate between to_date('2013-11-1','yyyy-mm-dd') and to_date('2014-1-1','yyyy-mm-dd') group by t.sitecode,t.sitename,to_char(t.checkdate,'mm') ) t1 left outer join (select t.sitecode as sitecode,t.sitename as sitename,to_char(t.checkdate,'mm') as datePeriod,count(*) as overnum from t_checkinfo t where t.checkdate between to_date('2013-11-1','yyyy-mm-dd') and to_date('2014-1-1','yyyy-mm-dd') and t.ifoverload=2 group by t.sitecode,t.sitename ,to_char(t.checkdate,'mm') ) t2 on t1.sitecode=t2.sitecode and t1.sitename=t2.sitename and t1.dateperiod=t2.dateperiod order by sitecode ,dateperiod desc
4. 季度统计,所有的:
select t1.sitecode as sitecode,t1.sitename as sitename,t1.dateperiod as dateperiod ,t1.allnum as allnumber,nvl(t2.overnum,0) as overnumber,nvl(to_char(t2.overnum/t1.allnum*100,'990.00'),0) as overpercent from (select t.sitecode as sitecode,t.sitename as sitename,to_char(t.checkdate,'q') as datePeriod,count(*) as allnum from t_checkinfo t where t.checkdate between to_date('2013-5-1','yyyy-mm-dd') and to_date('2014-1-1','yyyy-mm-dd') group by t.sitecode,t.sitename,to_char(t.checkdate,'q') ) t1 left outer join (select t.sitecode as sitecode,t.sitename as sitename,to_char(t.checkdate,'q') as datePeriod,count(*) as overnum from t_checkinfo t where t.checkdate between to_date('2013-5-1','yyyy-mm-dd') and to_date('2014-1-1','yyyy-mm-dd') and t.ifoverload=2 group by t.sitecode,t.sitename ,to_char(t.checkdate,'q') ) t2 on t1.sitecode=t2.sitecode and t1.sitename=t2.sitename and t1.dateperiod=t2.dateperiod order by sitecode ,dateperiod desc
5. 年统计,,所有的:
select t1.sitecode as sitecode,t1.sitename as sitename,t1.dateperiod as dateperiod ,t1.allnum as allnumber,nvl(t2.overnum,0) as overnumber,nvl(to_char(t2.overnum/t1.allnum*100,'990.00'),0) as overpercent from (select t.sitecode as sitecode,t.sitename as sitename,to_char(t.checkdate,'yyyy') as datePeriod,count(*) as allnum from t_checkinfo t where t.checkdate between to_date('2011-5-1','yyyy-mm-dd') and to_date('2014-1-1','yyyy-mm-dd') group by t.sitecode,t.sitename,to_char(t.checkdate,'yyyy') ) t1 left outer join (select t.sitecode as sitecode,t.sitename as sitename,to_char(t.checkdate,'yyyy') as datePeriod,count(*) as overnum from t_checkinfo t where t.checkdate between to_date('2011-5-1','yyyy-mm-dd') and to_date('2014-1-1','yyyy-mm-dd') and t.ifoverload=2 group by t.sitecode,t.sitename ,to_char(t.checkdate,'yyyy') ) t2 on t1.sitecode=t2.sitecode and t1.sitename=t2.sitename and t1.dateperiod=t2.dateperiod order by sitecode ,dateperiod desc
----------------------------------------------------------------------------------
原来:时间年对比:站点数据
select site.ctrl_site_name as city,to_char(checkdate,'yyyy') as time, count(t.checkid) as jiancenum,
sum(decode(t.ispunished,'0',0,1)) as chaozainum, sum(decode(t.overweight,'0.00', t.overweight, '.00', t.overweight,'','0', t.overweight))
as totalnum,
round(sum(decode(t.ispunished,'0',0,1)) / count(t.checkid) ,4) * 100 as overrun from
t_checkinfo t , t_ctrl_site site , t_organization c where
t.sitecode = site.ctrl_code and c.o_orgcode = site.region_name and t.sitecode in ('1406022001') and site.region_name = '140602' and
t.ifcertificate='0' and t.overpercent >= 0.1 and t.weight >= 30.0 and (to_char(t.checkdate, 'yyyy') between '2012' and '2013') group by
site.ctrl_site_name,to_char(checkdate,'yyyy') order by to_char(checkdate,'yyyy');
原来:区域对比:站点数据 : sqlsite
select site.ctrl_site_name as city,max(to_char(checkdate,'yyyy-mm-dd')) as time, count(t.checkid) as jiancenum,
sum(decode(t.ispunished,'0',0,1)) as chaozainum, sum(decode(t.overweight,'0.00', t.overweight, '.00', t.overweight,'','0', t.overweight))
as totalnum,
round(sum(decode(t.ispunished,'0',0,1)) / count(t.checkid) ,4) * 100 as overrun from
t_checkinfo t , t_ctrl_site site , t_organization c where
t.sitecode = site.ctrl_code and c.o_orgcode = site.region_name and t.sitecode in ('1406021001') and site.region_name = '140602' and
t.ifcertificate='0' and t.weight >= 10.0 and (to_char(t.chkIntimestamp, 'yyyy-mm-dd') between '2014-01-05' and '2014-01-07'
or to_char(t.chkouttimestamp, 'yyyy-mm-dd') between '2014-01-05' and '2014-01-07') group by site.ctrl_site_name
原来:时间年对比:检测车数据
select site.ctrl_site_name as city,to_char(checkdate,'yyyy') as time, count(t.checkid) as jiancenum,
sum(decode(t.ispunished,'0',0,1)) as chaozainum, sum(decode(t.overweight,'0.00', t.overweight, '.00', t.overweight,'','0', t.overweight))
as totalnum,
round(sum(decode(t.ispunished,'0',0,1)) / count(t.checkid) ,4) * 100 as overrun from
t_checkinfo t , t_ctrl_site site , t_organization c where
t.sitecode = site.ctrl_code and c.o_orgcode = site.region_name and t.sitecode in ('1406022001') and site.region_name = '140602' and
t.ifcertificate='0' and t.overpercent >= 0.1 and t.weight >= 30.0 and (to_char(t.checkdate, 'yyyy') between '2012' and '2013') group by
site.ctrl_site_name,to_char(checkdate,'yyyy') order by to_char(checkdate,'yyyy')
原来:区域天对比:站点数据
select site.ctrl_site_name as city,max(to_char(checkdate,'yyyy-mm-dd')) as time, count(t.checkid) as jiancenum,
sum(decode(t.ispunished,'0',0,1)) as chaozainum, sum(decode(t.overweight,'0.00', t.overweight, '.00', t.overweight,'','0', t.overweight))
as totalnum,
round(sum(decode(t.ispunished,'0',0,1)) / count(t.checkid) ,4) * 100 as overrun from
t_checkinfo t , t_ctrl_site site , t_organization c where
t.sitecode = site.ctrl_code and c.o_orgcode = site.region_name and t.sitecode in ('1406021001') and site.region_name = '140602' and
t.ifcertificate='0' and t.weight >= 10.0 and
(to_char(t.chkIntimestamp, 'yyyy-mm-dd') between '2014-01-05' and '2014-01-07' or to_char(t.chkouttimestamp, 'yyyy-mm-dd') between '2014-01-05' and '2014-01-07')
group by site.ctrl_site_name
天统计,所有统计(鲁最新SQL语句)
select t1.sitecode as sitecode,t1.sitename as sitename,to_char(t1.dateperiod,'yyyy-mm-dd') as dateperiod ,t1.allnum as allnumber,
nvl(t2.overnum,0) as overnumber,nvl(to_char(t2.overnum/t1.allnum*100,'990.00'),0) as overpercent from
(select t.sitecode as sitecode,t.sitename as sitename,trunc(t.checkdate,'dd') as datePeriod,count(*) as allnum from t_checkinfo t where
t.checkdate between to_date('2013-12-27','yyyy-mm-dd') and to_date('2014-01-03','yyyy-mm-dd') group by
t.sitecode,t.sitename,trunc(t.checkdate,'dd') ) t1
left outer join
(select t.sitecode as sitecode,t.sitename as sitename,trunc(t.checkdate,'dd') as datePeriod,count(*) as overnum from t_checkinfo t where
t.checkdate between to_date('2013-12-27','yyyy-mm-dd') and to_date('2014-01-03','yyyy-mm-dd') and t.ifoverload=2 group by
t.sitecode,t.sitename ,trunc(t.checkdate,'dd') ) t2 on t1.sitecode=t2.sitecode and t1.sitename=t2.sitename and t1.dateperiod=t2.dateperiod order by
sitecode ,dateperiod desc
鲁,周,所有
select t1.sitecode as sitecode,t1.sitename as sitename,t1.dateperiod as dateperiod ,t1.allnum as allnumber,
nvl(t2.overnum,0) as overnumber,nvl(to_char(t2.overnum/t1.allnum*100,'990.00'),0) as overpercent from
(select t.sitecode as sitecode,t.sitename as sitename,to_char(t.checkdate,'iw') as datePeriod,count(*) as allnum from t_checkinfo t where
t.checkdate between to_date('2013-12-1','yyyy-mm-dd') and to_date('2014-1-1','yyyy-mm-dd') group by
t.sitecode,t.sitename,to_char(t.checkdate,'iw') ) t1
left outer join
(select t.sitecode as sitecode,t.sitename as sitename,to_char(t.checkdate,'iw') as datePeriod,count(*) as overnum from t_checkinfo t where
t.checkdate between to_date('2013-12-1','yyyy-mm-dd') and to_date('2014-1-1','yyyy-mm-dd') and t.ifoverload=2 group by
t.sitecode,t.sitename ,to_char(t.checkdate,'iw') ) t2 on t1.sitecode=t2.sitecode and t1.sitename=t2.sitename and t1.dateperiod=t2.dateperiod order by
sitecode ,dateperiod desc
鲁,周,某区县
select t1.sitecode as sitecode,t1.sitename as sitename,t1.dateperiod as dateperiod ,t1.allnum as allnumber,
nvl(t2.overnum,0) as overnumber,nvl(to_char(t2.overnum/t1.allnum*100,'990.00'),0) as overpercent from
(select t.sitecode as sitecode,t.sitename as sitename,to_char(t.checkdate,'iw') as datePeriod,count(*) as allnum from t_checkinfo t where
t.checkdate between to_date('2013-12-1','yyyy-mm-dd') and to_date('2014-1-1','yyyy-mm-dd') and t.countycode='140602' group by
t.sitecode,t.sitename,to_char(t.checkdate,'iw') ) t1
left outer join
(select t.sitecode as sitecode,t.sitename as sitename,to_char(t.checkdate,'iw') as datePeriod,count(*) as overnum from t_checkinfo t where
t.checkdate between to_date('2013-12-1','yyyy-mm-dd') and to_date('2014-1-1','yyyy-mm-dd') and t.countycode='140602' and t.ifoverload=2 group by
t.sitecode,t.sitename ,to_char(t.checkdate,'iw') ) t2 on t1.sitecode=t2.sitecode and t1.sitename=t2.sitename and t1.dateperiod=t2.dateperiod order by
sitecode ,dateperiod desc
鲁,周,某站点
select t1.sitecode as sitecode,t1.sitename as sitename,t1.dateperiod as dateperiod ,t1.allnum as allnumber,
nvl(t2.overnum,0) as overnumber,nvl(to_char(t2.overnum/t1.allnum*100,'990.00'),0) as overpercent from
(select t.sitecode as sitecode,t.sitename as sitename,to_char(t.checkdate,'iw') as datePeriod,count(*) as allnum from t_checkinfo t where
t.checkdate between to_date('2013-12-1','yyyy-mm-dd') and to_date('2014-1-1','yyyy-mm-dd') and t.sitecode='1406021001' group by
t.sitecode,t.sitename,to_char(t.checkdate,'iw') ) t1
left outer join
(select t.sitecode as sitecode,t.sitename as sitename,to_char(t.checkdate,'iw') as datePeriod,count(*) as overnum from t_checkinfo t where
t.checkdate between to_date('2013-12-1','yyyy-mm-dd') and to_date('2014-1-1','yyyy-mm-dd') and t.sitecode='1406021001' and t.ifoverload=2 group by
t.sitecode,t.sitename ,to_char(t.checkdate,'iw') ) t2 on t1.sitecode=t2.sitecode and t1.sitename=t2.sitename and t1.dateperiod=t2.dateperiod order by
sitecode ,dateperiod desc
鲁,季度,所有
select t1.sitecode as sitecode,t1.sitename as sitename,t1.dateperiod as dateperiod ,t1.allnum as allnumber,
nvl(t2.overnum,0) as overnumber,nvl(to_char(t2.overnum/t1.allnum*100,'990.00'),0) as overpercent from
(select t.sitecode as sitecode,t.sitename as sitename,to_char(t.checkdate,'q') as datePeriod,count(*) as allnum from t_checkinfo t where
t.checkdate between to_date('2013-5-1','yyyy-mm-dd') and to_date('2014-1-1','yyyy-mm-dd') group by
t.sitecode,t.sitename,to_char(t.checkdate,'q') ) t1
left outer join
(select t.sitecode as sitecode,t.sitename as sitename,to_char(t.checkdate,'q') as datePeriod,count(*) as overnum from t_checkinfo t where
t.checkdate between to_date('2013-5-1','yyyy-mm-dd') and to_date('2014-1-1','yyyy-mm-dd') and t.ifoverload=2 group by
t.sitecode,t.sitename ,to_char(t.checkdate,'q') ) t2 on
t1.sitecode=t2.sitecode and t1.sitename=t2.sitename and t1.dateperiod=t2.dateperiod order by sitecode ,dateperiod desc
//按区域查询代码示例,现在有问题,稍后需要重新检查错误(这次对了)
select t1.sitecode as sitecode,t1.sitename as sitename,t1.dateperiod as dateperiod ,t1.allnum as allnumber,
nvl(t2.overnum,0) as overnumber,nvl(to_char(t2.overnum/t1.allnum*100,'990.00'),0) as overpercent from
(select t.sitecode as sitecode,t.sitename as sitename,max(to_char(checkdate,'yyyy-mm-dd')) as datePeriod,count(*) as allnum from t_checkinfo t where
t.checkdate between to_date('2013-12-1','yyyy-mm-dd') and to_date('2014-1-1','yyyy-mm-dd') and t.sitecode='1406021001' group by
t.sitecode,t.sitename ) t1
left outer join
(select t.sitecode as sitecode,t.sitename as sitename,max(to_char(checkdate,'yyyy-mm-dd')) as datePeriod,count(*) as overnum from t_checkinfo t where
t.checkdate between to_date('2013-12-1','yyyy-mm-dd') and to_date('2014-1-1','yyyy-mm-dd') and t.sitecode='1406021001' and t.ifoverload=2 group by
t.sitecode,t.sitename ) t2
on t1.sitecode=t2.sitecode and t1.sitename=t2.sitename;
测试程序里生成的sql语句
select t1.sitename as sitename,t1.dateperiod as dateperiod , t1.allnum as allnumber, nvl(t2.overnum,0) as overnumber,
t1.alloverweightnum as alloverweight, nvl(to_char(t2.overnum/t1.allnum*100,'990.00'),0) as overpercent, t1.sitecode as sitecode from
(select t.sitecode as sitecode,t.sitename as sitename, to_char(t.checkdate,'yyyy') as datePeriod, count(*) as allnum,
sum(decode(t.overweight,'0.00', t.overweight, '.00', t.overweight,'','0', t.overweight)) as alloverweightnum from
t_checkinfo t where 1=1 and t.sitecode in ('1406021001') and to_char(t.checkdate, 'yyyy') between '2012' and '2013'
group by t.sitecode,t.sitename, to_char(t.checkdate,'yyyy') ) t1
left outer join
(select t.sitecode as sitecode,t.sitename as sitename, to_char(t.checkdate,'yyyy') as datePeriod,
count(*) as overnum, sum(decode(t.overweight,'0.00', t.overweight, '.00', t.overweight,'','0', t.overweight)) as
alloverweightnum from t_checkinfo t where 1=1 and t.sitecode in ('1406021001') and t.ifoverload=2 and
to_char(t.checkdate, 'yyyy') between '2012' and '2013'
group by t.sitecode,t.sitename , to_char(t.checkdate,'yyyy') ) t2 on
t1.sitecode=t2.sitecode and t1.sitename=t2.sitename and t1.dateperiod=t2.dateperiod order by sitecode ,dateperiod desc
to_char(t.checkdate, 'yyyy') between '2012' and '2013';
select t.overweight,t.checkdate from t_checkinfo t where t.overweight is not null and t.overweight!=0 and t.ifoverload=0 order by t.checkdate;
---------------------------------------------------------------------------------
select t.*, t.rowid from t_checkinfo t
对比类型compareType 按什么时间对比compareNum 开始时间结束时间 市区city 站点类型stationType 站点stations 分析内容compareContent
总吨数weight 超载率outOverPercent 生成图形imgType
select site.ctrl_site_name as city,to_char(checkdate,'yyyy') as time, count(t.checkid) as jiancenum, sum(decode(t.ispunished,'0',0,1)) as chaozainum, sum(decode(t.overweight,'0.00', t.overweight, '.00', t.overweight,'','0', t.overweight)) as totalnum, round(sum(decode(t.ispunished,'0',0,1)) / count(t.checkid) ,4) * 100 as overrun from t_checkinfo t , t_ctrl_site site , t_organization c where t.sitecode = site.ctrl_code and c.o_orgcode = site.region_name and t.sitecode in ('1406022001') and site.region_name = '140602' and t.ifcertificate='0' and t.overpercent >= 0.1 and t.weight >= 30.0 and (to_char(t.checkdate, 'yyyy') between '2012' and '2013') group by site.ctrl_site_name,to_char(checkdate,'yyyy') order by to_char(checkdate,'yyyy')
select site.ctrl_site_name as city,to_char(checkdate,'yyyy') as time, count(t.checkid) as jiancenum,
sum(decode(t.ispunished,'0',0,1)) as chaozainum, sum(decode(t.overweight,'0.00', t.overweight, '.00', t.overweight,'','0', t.overweight))
as totalnum,
round(sum(decode(t.ispunished,'0',0,1)) / count(t.checkid) ,4) * 100 as overrun from
t_checkinfo t , t_ctrl_site site , t_organization c where
t.sitecode = site.ctrl_code and c.o_orgcode = site.region_name and t.sitecode in ('1406022001') and site.region_name = '140602' and
t.ifcertificate='0' and t.overpercent >= 0.1 and t.weight >= 30.0 and (to_char(t.checkdate, 'yyyy') between '2012' and '2013') group by
site.ctrl_site_name,to_char(checkdate,'yyyy') order by to_char(checkdate,'yyyy')
t1.allnum as allnumber,nvl(t2.overnum,0) as overnumber,nvl(to_char(t2.overnum/t1.allnum*100,'990.00'),0) as overpercent
select t1.sitename as sitename,t1.dateperiod as dateperiod , t1.allnum as allnumber, nvl(t2.overnum,0) as overnumber,
t1.alloverweightnum as alloverweight, nvl(to_char(t2.overnum/t1.allnum*100,'990.00'),0) as overpercent, t1.sitecode as sitecode from
(select t.sitecode as sitecode,t.sitename as sitename, to_char(t.checkdate,'yyyy') as datePeriod, count(*) as allnum,
sum(decode(t.overweight,'0.00', t.overweight, '.00', t.overweight,'','0', t.overweight)) as alloverweightnum from
t_checkinfo t where 1=1 and t.sitecode in ('1406021001') and t.checkdate between to_date('2012','yyyy-mm-dd') and to_date('2013','yyyy-mm-dd')
group by t.sitecode,t.sitename, to_char(t.checkdate,'yyyy') ) t1
left outer join
(select t.sitecode as sitecode,t.sitename as sitename, to_char(t.checkdate,'yyyy') as datePeriod,
count(*) as overnum, sum(decode(t.overweight,'0.00', t.overweight, '.00', t.overweight,'','0', t.overweight)) as
alloverweightnum from t_checkinfo t where 1=1 and t.sitecode in ('1406021001') and t.ifoverload=2 and
t.checkdate between to_date('2012','yyyy-mm-dd') and to_date('2013','yyyy-mm-dd')
group by t.sitecode,t.sitename , to_char(t.checkdate,'yyyy') ) t2 on
t1.sitecode=t2.sitecode and t1.sitename=t2.sitename and t1.dateperiod=t2.dateperiod order by sitecode ,dateperiod desc
-------------------------------------------------------------------------------
汇总报表sql:
---按照站点,一段时间内的站点总统计
select t1.sitecode as sitecode,t1.sitename as sitename
,t1.allnum as allnumber,nvl(t2.overnum,0) as overnumber,nvl(to_char(t2.overnum/t1.allnum*100,'990.00'),0) as overpercent
from (select t.sitecode as sitecode,t.sitename as sitename ,count(*) as allnum from t_checkinfo t
where t.checkdate between to_date('2014-01-01','yyyy-mm-dd') and to_date('2014-01-07','yyyy-mm-dd')
and t.countycode='140602' group by t.sitecode,t.sitename ) t1
left outer join
(select t.sitecode as sitecode,t.sitename as sitename ,count(*) as overnum from t_checkinfo t
where t.checkdate between to_date('2014-01-01','yyyy-mm-dd') and to_date('2014-01-07','yyyy-mm-dd') and t.countycode='140602'
and t.ifoverload=2 group by t.sitecode,t.sitename ) t2 on t1.sitecode=t2.sitecode and t1.sitename=t2.sitename order by sitecode desc
---站点统计
不选择区县,统计一段时间内所有的站点:select t1.sitecode as sitecode,t1.sitename as sitename, t1.allnum as allnumber,nvl(t2.overnum,0) as overnumber,nvl(to_char(t2.overnum/t1.allnum*100,'990.00'),0) as overpercent from (select t.sitecode as sitecode,t.sitename as sitename, count(*) as allnum from t_checkinfo t where t.checkdate between to_date('2014-01-01','yyyy-mm-dd') and to_date('2014-01-08','yyyy-mm-dd') group by t.sitecode,t.sitename ) t1 left outer join (select t.sitecode as sitecode,t.sitename as sitename, count(*) as overnum from t_checkinfo t where t.checkdate between to_date('2014-01-01','yyyy-mm-dd') and to_date('2014-01-08','yyyy-mm-dd') and t.ifoverload=2 group by t.sitecode,t.sitename ) t2 on t1.sitecode=t2.sitecode and t1.sitename=t2.sitename order by sitecode desc
选择区县,统计一段时间内容此区县下的站点:select t1.sitecode as sitecode,t1.sitename as sitename, t1.allnum as allnumber,nvl(t2.overnum,0) as overnumber,nvl(to_char(t2.overnum/t1.allnum*100,'990.00'),0) as overpercent from (select t.sitecode as sitecode,t.sitename as sitename, count(*) as allnum from t_checkinfo t where t.checkdate between to_date('2014-01-01','yyyy-mm-dd') and to_date('2014-01-08','yyyy-mm-dd') and t.countycode='140622' group by t.sitecode,t.sitename ) t1 left outer join (select t.sitecode as sitecode,t.sitename as sitename, count(*) as overnum from t_checkinfo t where t.checkdate between to_date('2014-01-01','yyyy-mm-dd') and to_date('2014-01-08','yyyy-mm-dd') and t.countycode='140622' and t.ifoverload=2 group by t.sitecode,t.sitename ) t2 on t1.sitecode=t2.sitecode and t1.sitename=t2.sitename order by sitecode desc
---区县统计:
统计所有区县:select t1.sitecode as sitecode,t1.sitename as sitename, t1.allnum as allnumber,nvl(t2.overnum,0) as overnumber,nvl(to_char(t2.overnum/t1.allnum*100,'990.00'),0) as overpercent from (select t.sitecode as sitecode,t.sitename as sitename, count(*) as allnum from t_checkinfo t where t.checkdate between to_date('2014-01-01','yyyy-mm-dd') and to_date('2014-01-08','yyyy-mm-dd') and t.countycode='140622' group by t.sitecode,t.sitename ) t1 left outer join (select t.sitecode as sitecode,t.sitename as sitename, count(*) as overnum from t_checkinfo t where t.checkdate between to_date('2014-01-01','yyyy-mm-dd') and to_date('2014-01-08','yyyy-mm-dd') and t.countycode='140622' and t.ifoverload=2 group by t.sitecode,t.sitename ) t2 on t1.sitecode=t2.sitecode and t1.sitename=t2.sitename order by sitecode desc
统计具体区县:select t1.countycode as countycode,t1.countyname as countyname, t1.allnum as allnumber,nvl(t2.overnum,0) as overnumber,nvl(to_char(t2.overnum/t1.allnum*100,'990.00'),0) as overpercent from (select countycode as countycode,t.countyname as countyname, count(*) as allnum from t_checkinfo t where t.checkdate between to_date('2014-01-01','yyyy-mm-dd') and to_date('2014-01-08','yyyy-mm-dd') and t.countycode='140624' group by t.countycode,t.countyname) t1 left outer join (select countycode as countycode,t.countyname as countyname, count(*) as overnum from t_checkinfo t where t.checkdate between to_date('2014-01-01','yyyy-mm-dd') and to_date('2014-01-08','yyyy-mm-dd') and t.countycode='140624' and t.ifoverload=2 group by t.countycode,t.countyname ) t2 on t1.countycode=t2.countycode and t1.countyname=t2.countyname order by countycode desc
统计具体区县,带站点编号:select t1.countycode as countycode,t1.countyname as countyname, t1.allnum as allnumber,nvl(t2.overnum,0) as overnumber,nvl(to_char(t2.overnum/t1.allnum*100,'990.00'),0) as overpercent from (select countycode as countycode,t.countyname as countyname, count(*) as allnum from t_checkinfo t where t.checkdate between to_date('2014-01-01','yyyy-mm-dd') and to_date('2014-01-08','yyyy-mm-dd') and t.countycode='140624' and t.sitecode='1406242020' group by t.countycode,t.countyname) t1 left outer join (select countycode as countycode,t.countyname as countyname, count(*) as overnum from t_checkinfo t where t.checkdate between to_date('2014-01-01','yyyy-mm-dd') and to_date('2014-01-08','yyyy-mm-dd') and t.countycode='140624' and t.sitecode='1406242020' and t.ifoverload=2 group by t.countycode,t.countyname ) t2 on t1.countycode=t2.countycode and t1.countyname=t2.countyname order by countycode desc
分享到:
相关推荐
某超限高层的抗震性能分析,徐芳,,本文以上海某大厦超限高层建筑为研究对象,应用通用有限元分析软件ANSYS对其进行抗震分析,主要包括各种荷载的计算,结构的内力计�
运用midas Building进行超限分析基本流程指导书
本文针对神华集团乌达矿业有限责任公司五虎山煤矿开采现状,在不考虑设备故障的情况下,找出导致瓦斯超限的基本事件,运用事故树分析方法,评价各个基本事件的结构重要度,并且根据结构重要度的不同分别采取预防措施,防止...
超限数据分析.pdf
在事故理论和灾害防治理论指导下,通过理论分析和数理统计研究了赵庄矿瓦斯超限致因因素,对地质构造、矿山压力等因素对瓦斯超限的影响规律进行了分析;结合瓦斯超限致因因素,构建了瓦斯超限孕育发展模型,通过瓦斯大量...
由于煤矿综采工作面回采工艺、回采方法以及通风方式不合理,很容易造成工作面上隅角瓦斯超限,若不采取合理有效的处理方法,不仅影响着整个工作面回采效率,而且很容易发生瓦斯事故。以西山煤电集团屯兰矿12501工作面为...
超限战.exe超限战.exe
某超限高层建筑静动力风荷载分析,杨晓利,杨志勇,风荷载是建筑物的主要动荷载之一,尤其对于风敏感的复杂高层建筑结构,风荷载引起的效应在总荷载效应中占有相当大的比重,甚至起
应用矿山安全理论、采矿工程技术、计算机技术、GIS技术、科学计算等方法,研究瓦斯灾害的超前预警理论...针对成庄矿瓦斯灾害特征与规律,制定瓦斯超限及突出预警指标及规则,开发预警系统,实现了瓦斯预警及管理的智能化。
剪力墙结构超限高层建筑弹塑性时程分析,吴锡文,李书进,近年来超限高层建筑大量涌现,为了解该类建筑结构的特性,本文以某剪力墙结构的超限高层建筑为工程背景,运用abaqus大型有限元软件
通过这些资料学习,可以了解最新的一种ELM算法,这种算法在今后有很大的应用前景,非常不错
以大佛寺矿为例,分析了矿井瓦斯超限原因,介绍了矿井采取的一系列有针对性的瓦斯防治措施:加强矿井通风管理、综合性瓦斯抽放措施、加强特殊地点特殊时段的瓦斯管理、建设备用安全电源、强化安全管理等手段,降低了矿井...
结合毕节市煤矿企业2017年以来瓦斯监控数据,针对瓦斯监控的时间、地点、原因进行了统计分析,结果发现:报警次数年度内集中在7、8、9、11月份、一天内集中在8~17时;掘进工作面、采煤工作面是瓦斯浓度最容易超限场所,...
针对郁山煤业有限公司33061回风巷掘进工作面掘进期间的一次瓦斯超限事故,分析了事故发生的原因,得出了事故的直接原因与间接原因,提出了针对性的防范对策,实现了安全掘进,确保了矿井的安全生产。
瓦斯超限分析管理制度汇编.doc
超限高层抗震专项审查分析报告书
在管理上是无序的,开发过程是非正式和混乱的,计划期限和成本目标通常超限,项目的成功取 决于个人英雄式的行为,在人员发生变动时项目往往陷入灾难,那么很难说这个项目会获得成功。 从这个意义上说,软件项目管理...
自己编写的 用超限差值法,来生成网格,自己编写的 用超限差值法,来生成网格
对长距离煤巷掘进工作面瓦斯超限进行了综合分析,提出了治理煤壁瓦斯大量涌出的思路。在无法用通风的方法解决瓦斯涌出量增大的情况下,采取施工本煤层瓦斯抽放钻孔及提高工作面抽放能力来治理煤巷瓦斯超限的综合措施,...
某项目超限轮扣模板支撑安全专项施工方案.docx