当前位置:网站首页>Illegal behavior analysis 1
Illegal behavior analysis 1
2022-07-07 23:24:00 【Little fat is so fierce!】
spark-sql> select tt1.tjrq
> ,tt1.dr_sgs
> ,tt1.jn_sgs
> ,tt1.qntq_sgs
>
> ,tt1.dr_swsgs
> ,tt1.jn_swsgs
> ,tt1.qntq_swsgs
>
> ,tt1.dr_swrs
> ,tt1.jn_swrs
> ,tt1.qntq_swrs
>
> ,NVL(round((abs(tt1.dr_sgs-tt1.qntq_sgs)/NVL(tt1.qntq_sgs,1))*100,2),0) as tb_sgs
> ,if(tt1.dr_sgs-tt1.qntq_sgs>0," rising ",' falling ') as tb_sgs_bj
>
> ,NVL(round((abs(tt1.dr_swsgs-tt1.qntq_swsgs)/NVL(tt1.qntq_swsgs,1))*100,2),0) as tb_swsgs
> ,if(tt1.dr_swsgs-tt1.qntq_swsgs>0," rising ",' falling ') as tb_swsgs_bj
>
> ,NVL(round((abs(tt1.dr_swrs-tt1.qntq_swrs)/NVL(tt1.qntq_swrs,1))*100,2),0) as tb_swrs
> ,if(tt1.dr_swrs-tt1.qntq_swrs>0," rising ",' falling ') as tb_swrs_bj
> from(
> select t1.tjrq
> ,t1.dr_sgs
> ,t1.dr_swsgs
> ,t1.dr_swrs
>
> ,sum(t1.dr_sgs)over (partition by substr(t1.tjrq,1,4))as jn_sgs
> ,lag(t1.dr_sgs,1,1)over (partition by substr(t1.tjrq,6,5)order by substr(t1.tjrq,1,4))as qntq_sgs
>
> ,sum(t1.dr_swsgs)over (partition by substr(t1.tjrq,1,4))as jn_swsgs
> ,lag(t1.dr_swsgs,1,1)over (partition by substr(t1.tjrq,6,5)order by substr(t1.tjrq,1,4))as qntq_swsgs
>
> ,sum(t1.dr_swrs)over (partition by substr(t1.tjrq,1,4))as jn_swrs
> ,lag(t1.dr_swrs,1,1)over (partition by substr(t1.tjrq,6,5)order by substr(t1.tjrq,1,4))as qntq_swrs
> from(
> select substr(sgfssj,1,10)as tjrq
> ,count(1)as dr_sgs -- Number of accidents of the day
> ,sum(if(swrs7>0,1,0))as dr_swsgs -- Number of fatal accidents on that day
> ,sum(swrs7)as dr_swrs -- The death toll of the day
> from dwd.base_acd_file
> group by substr(sgfssj,1,10)
> )t1
> )tt1
> order by tt1.tjrq;
Time taken: 6.484 seconds, Fetched 4966 row(s)
22/07/05 15:46:19 INFO thriftserver.SparkSQLCLIDriver: Time taken: 6.484 seconds, Fetched 4966 row(s)
spark-sql> select tt1.tjrq
> ,tt1.dr_sgs
> ,tt1.jn_sgs
> ,tt1.qntq_sgs
>
> ,tt1.dr_swsgs
> ,tt1.jn_swsgs
> ,tt1.qntq_swsgs
>
> ,tt1.dr_swrs
> ,tt1.jn_swrs
> ,tt1.qntq_swrs
>
> ,tt1.dr_ssrs
> ,tt1.jn_ssrs
> ,tt1.qntq_ssrs
>
> ,tt1.dr_zjccss
> ,tt1.jn_zjccss
> ,tt1.qntq_zjccss
>
> ,NVL(round((abs(tt1.dr_sgs-tt1.qntq_sgs)/NVL(tt1.qntq_sgs,1))*100,2),0) as tb_sgs
> ,if(tt1.dr_sgs-tt1.qntq_sgs>0," rising ",' falling ') as tb_sgs_bj
>
> ,NVL(round((abs(tt1.dr_swsgs-tt1.qntq_swsgs)/NVL(tt1.qntq_swsgs,1))*100,2),0) as tb_swsgs
> ,if(tt1.dr_swsgs-tt1.qntq_swsgs>0," rising ",' falling ') as tb_swsgs_bj
>
> ,NVL(round((abs(tt1.dr_swrs-tt1.qntq_swrs)/NVL(tt1.qntq_swrs,1))*100,2),0) as tb_swrs
> ,if(tt1.dr_swrs-tt1.qntq_swrs>0," rising ",' falling ') as tb_swrs_bj
>
> ,NVL(round((abs(tt1.dr_ssrs-tt1.qntq_ssrs)/NVL(tt1.qntq_ssrs,1))*100,2),0) as tb_ssrs
> ,if(tt1.dr_ssrs-tt1.qntq_ssrs>0," rising ",' falling ') as tb_ssrs_bj
>
> ,NVL(round((abs(tt1.dr_zjccss-tt1.qntq_zjccss)/NVL(tt1.qntq_zjccss,1))*100,2),0) as tb_zjccss
> ,if(tt1.dr_zjccss-tt1.qntq_zjccss>0," rising ",' falling ') as tb_zjccss_bj
> from(
> select t1.tjrq
> ,t1.dr_sgs
> ,t1.dr_swsgs
> ,t1.dr_swrs
> ,t1.dr_ssrs
> ,t1.dr_zjccss
>
> ,sum(t1.dr_sgs)over (partition by substr(t1.tjrq,1,4))as jn_sgs
> ,lag(t1.dr_sgs,1,1)over (partition by substr(t1.tjrq,6,5)order by substr(t1.tjrq,1,4))as qntq_sgs
>
> ,sum(t1.dr_swsgs)over (partition by substr(t1.tjrq,1,4))as jn_swsgs
> ,lag(t1.dr_swsgs,1,1)over (partition by substr(t1.tjrq,6,5)order by substr(t1.tjrq,1,4))as qntq_swsgs
>
> ,sum(t1.dr_swrs)over (partition by substr(t1.tjrq,1,4))as jn_swrs
> ,lag(t1.dr_swrs,1,1)over (partition by substr(t1.tjrq,6,5)order by substr(t1.tjrq,1,4))as qntq_swrs
>
> ,sum(t1.dr_ssrs)over (partition by substr(t1.tjrq,1,4))as jn_ssrs
> ,lag(t1.dr_ssrs,1,1)over (partition by substr(t1.tjrq,6,5)order by substr(t1.tjrq,1,4))as qntq_ssrs
>
> ,sum(t1.dr_zjccss)over (partition by substr(t1.tjrq,1,4))as jn_zjccss
> ,lag(t1.dr_zjccss,1,1)over (partition by substr(t1.tjrq,6,5)order by substr(t1.tjrq,1,4))as qntq_zjccss
> from(
> select substr(sgfssj,1,10)as tjrq
> ,count(1)as dr_sgs -- Number of accidents of the day
> ,sum(if(swrs7>0,1,0))as dr_swsgs -- Number of fatal accidents on that day
> ,sum(swrs7)as dr_swrs -- The death toll of the day
> ,sum(ssrs7)as dr_ssrs -- Number of injured on that day
> ,sum(zjccss)as dr_zjccss -- Direct property loss on that day
> from dwd.base_acd_file
> group by substr(sgfssj,1,10)
> )t1
> )tt1
> order by tt1.tjrq;
Time taken: 11.104 seconds, Fetched 4966 row(s)
22/07/05 15:56:13 INFO thriftserver.SparkSQLCLIDriver: Time taken: 11.104 seconds, Fetched 4966 row(s)
spark-sql> select tt1.tjrq
>
> ,tt1.dr_sgs
> ,tt1.jn_sgs
> ,tt1.qntq_sgs
> ,NVL(round((abs(tt1.dr_sgs-tt1.qntq_sgs)/NVL(tt1.qntq_sgs,1))*100,2),0) as tb_sgs
> ,if(tt1.dr_sgs-tt1.qntq_sgs>0," rising ",' falling ') as tb_sgs_bj
>
> ,tt1.dr_swsgs
> ,tt1.jn_swsgs
> ,tt1.qntq_swsgs
> ,NVL(round((abs(tt1.dr_swsgs-tt1.qntq_swsgs)/NVL(tt1.qntq_swsgs,1))*100,2),0) as tb_swsgs
> ,if(tt1.dr_swsgs-tt1.qntq_swsgs>0," rising ",' falling ') as tb_swsgs_bj
>
> ,tt1.dr_swrs
> ,tt1.jn_swrs
> ,tt1.qntq_swrs
> ,NVL(round((abs(tt1.dr_swrs-tt1.qntq_swrs)/NVL(tt1.qntq_swrs,1))*100,2),0) as tb_swrs
> ,if(tt1.dr_swrs-tt1.qntq_swrs>0," rising ",' falling ') as tb_swrs_bj
>
> ,tt1.dr_ssrs
> ,tt1.jn_ssrs
> ,tt1.qntq_ssrs
> ,NVL(round((abs(tt1.dr_ssrs-tt1.qntq_ssrs)/NVL(tt1.qntq_ssrs,1))*100,2),0) as tb_ssrs
> ,if(tt1.dr_ssrs-tt1.qntq_ssrs>0," rising ",' falling ') as tb_ssrs_bj
>
> ,tt1.dr_zjccss
> ,tt1.jn_zjccss
> ,tt1.qntq_zjccss
> ,NVL(round((abs(tt1.dr_zjccss-tt1.qntq_zjccss)/NVL(tt1.qntq_zjccss,1))*100,2),0) as tb_zjccss
> ,if(tt1.dr_zjccss-tt1.qntq_zjccss>0," rising ",' falling ') as tb_zjccss_bj
> from(
> select t1.tjrq
>
> ,t1.dr_sgs
> ,sum(t1.dr_sgs)over (partition by substr(t1.tjrq,1,4))as jn_sgs
> ,lag(t1.dr_sgs,1,1)over (partition by substr(t1.tjrq,6,5)order by substr(t1.tjrq,1,4))as qntq_sgs
>
> ,t1.dr_swsgs
> ,sum(t1.dr_swsgs)over (partition by substr(t1.tjrq,1,4))as jn_swsgs
> ,lag(t1.dr_swsgs,1,1)over (partition by substr(t1.tjrq,6,5)order by substr(t1.tjrq,1,4))as qntq_swsgs
>
> ,t1.dr_swrs
> ,sum(t1.dr_swrs)over (partition by substr(t1.tjrq,1,4))as jn_swrs
> ,lag(t1.dr_swrs,1,1)over (partition by substr(t1.tjrq,6,5)order by substr(t1.tjrq,1,4))as qntq_swrs
>
> ,t1.dr_ssrs
> ,sum(t1.dr_ssrs)over (partition by substr(t1.tjrq,1,4))as jn_ssrs
> ,lag(t1.dr_ssrs,1,1)over (partition by substr(t1.tjrq,6,5)order by substr(t1.tjrq,1,4))as qntq_ssrs
>
> ,t1.dr_zjccss
> ,sum(t1.dr_zjccss)over (partition by substr(t1.tjrq,1,4))as jn_zjccss
> ,lag(t1.dr_zjccss,1,1)over (partition by substr(t1.tjrq,6,5)order by substr(t1.tjrq,1,4))as qntq_zjccss
> from(
> select substr(sgfssj,1,10)as tjrq
> ,count(1)as dr_sgs -- Number of accidents of the day
> ,sum(if(swrs7>0,1,0))as dr_swsgs -- Number of fatal accidents on that day
> ,sum(swrs7)as dr_swrs -- The death toll of the day
> ,sum(ssrs7)as dr_ssrs -- Number of injured on that day
> ,sum(zjccss)as dr_zjccss -- Direct property loss on that day
> from dwd.base_acd_file
> group by substr(sgfssj,1,10)
> )t1
> )tt1
> order by tt1.tjrq;
Time taken: 9.019 seconds, Fetched 4966 row(s)
22/07/05 16:06:51 INFO thriftserver.SparkSQLCLIDriver: Time taken: 9.019 seconds, Fetched 4966 row(s)
spark-sql> create database dws;
Time taken: 0.829 seconds
22/07/05 16:08:44 INFO thriftserver.SparkSQLCLIDriver: Time taken: 0.829 seconds
spark-sql> use dws;
Time taken: 0.032 seconds
22/07/05 16:08:50 INFO thriftserver.SparkSQLCLIDriver: Time taken: 0.032 seconds
spark-sql> CREATE TABLE dws.app_acd_mrjq(
> tjrq STRING COMMENT ' Date of Statistics ',
>
> dr_sgs int COMMENT ' Number of accidents of the day ',
> jn_sgs int COMMENT ' Number of accidents this year ',
> tb_sgs double COMMENT ' Year on year number of accidents ',
> tb_sgs_bj STRING COMMENT ' Year on year accident number mark ',
>
> dr_swsgs int COMMENT ' Number of fatal accidents on that day ',
> jn_swsgs int COMMENT ' The number of fatal accidents this year ',
> tb_swsgs double COMMENT ' Number of fatal accidents year on year ',
> tb_swsgs_bj STRING COMMENT ' The number of fatal accidents marked on a year-on-year basis ',
>
> dr_swrs int COMMENT ' The death toll of the day ',
> jn_swrs int COMMENT ' The number of deaths this year ',
> tb_swrs double COMMENT ' Year on year death toll ',
> tb_swrs_bj STRING COMMENT ' Year on year mortality marker ',
>
> dr_ssrs int COMMENT ' Number of injured on that day ',
> jn_ssrs int COMMENT ' The number of injured this year ',
> tb_ssrs double COMMENT ' Year on year number of injuries ',
> tb_ssrs_bj STRING COMMENT ' Year on year injury mark ',
>
> dr_zjccss int COMMENT ' Property loss on that day ',
> jn_zjccss int COMMENT ' Property losses this year ',
> tb_zjccss double COMMENT ' Year on year property losses ',
> tb_zjccss_bj STRING COMMENT ' Year on year property loss mark '
> )
> ROW FORMAT DELIMITED
> FIELDS TERMINATED BY '^'
> STORED AS INPUTFORMAT 'org.apache.hadoop.mapred.TextInputFormat'
> OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
> location '/car/dws/app_acd_mrjq';
Time taken: 0.186 seconds
22/07/05 16:11:50 INFO thriftserver.SparkSQLCLIDriver: Time taken: 0.186 seconds
spark-sql> INSERT overwrite table dws.app_acd_mrjq
> select tt1.tjrq
> ,tt1.dr_sgs
> ,tt1.jn_sgs
> ,NVL(round((abs(tt1.dr_sgs-tt1.qntq_sgs)/NVL(tt1.qntq_sgs,1))*100,2),0) as tb_sgs
> ,if(tt1.dr_sgs-tt1.qntq_sgs>0," rising ",' falling ') as tb_sgs_bj
> ,tt1.dr_swsgs
> ,tt1.jn_swsgs
> ,NVL(round((abs(tt1.dr_swsgs-tt1.qntq_swsgs)/NVL(tt1.qntq_swsgs,1))*100,2),0) as tb_swsgs
> ,if(tt1.dr_swsgs-tt1.qntq_swsgs>0," rising ",' falling ') as tb_swsgs_bj
> ,tt1.dr_swrs
> ,tt1.jn_swrs
> ,NVL(round((abs(tt1.dr_swrs-tt1.qntq_swrs)/NVL(tt1.qntq_swrs,1))*100,2),0) as tb_swrs
> ,if(tt1.dr_swrs-tt1.qntq_swrs>0," rising ",' falling ') as tb_swrs_bj
> ,tt1.dr_ssrs
> ,tt1.jn_ssrs
> ,NVL(round((abs(tt1.dr_ssrs-tt1.qntq_ssrs)/NVL(tt1.qntq_ssrs,1))*100,2),0) as tb_ssrs
> ,if(tt1.dr_ssrs-tt1.qntq_ssrs>0," rising ",' falling ') as tb_ssrs_bj
> ,tt1.dr_zjccss
> ,tt1.jn_zjccss
> ,NVL(round((abs(tt1.dr_zjccss-tt1.qntq_zjccss)/NVL(tt1.qntq_zjccss,1))*100,2),0) as tb_zjccss
> ,if(tt1.dr_zjccss-tt1.qntq_zjccss>0," rising ",' falling ') as tb_zjccss_bj
> from(
> select t1.tjrq
> ,t1.dr_sgs
> ,sum(t1.dr_sgs)over (partition by substr(t1.tjrq,1,4))as jn_sgs
> ,lag(t1.dr_sgs,1,1)over (partition by substr(t1.tjrq,6,5)order by substr(t1.tjrq,1,4))as qntq_sgs
> ,t1.dr_swsgs
> ,sum(t1.dr_swsgs)over (partition by substr(t1.tjrq,1,4))as jn_swsgs
> ,lag(t1.dr_swsgs,1,1)over (partition by substr(t1.tjrq,6,5)order by substr(t1.tjrq,1,4))as qntq_swsgs
> ,t1.dr_swrs
> ,sum(t1.dr_swrs)over (partition by substr(t1.tjrq,1,4))as jn_swrs
> ,lag(t1.dr_swrs,1,1)over (partition by substr(t1.tjrq,6,5)order by substr(t1.tjrq,1,4))as qntq_swrs
> ,t1.dr_ssrs
> ,sum(t1.dr_ssrs)over (partition by substr(t1.tjrq,1,4))as jn_ssrs
> ,lag(t1.dr_ssrs,1,1)over (partition by substr(t1.tjrq,6,5)order by substr(t1.tjrq,1,4))as qntq_ssrs
> ,t1.dr_zjccss
> ,sum(t1.dr_zjccss)over (partition by substr(t1.tjrq,1,4))as jn_zjccss
> ,lag(t1.dr_zjccss,1,1)over (partition by substr(t1.tjrq,6,5)order by substr(t1.tjrq,1,4))as qntq_zjccss
> from(
> select substr(sgfssj,1,10)as tjrq
> ,count(1)as dr_sgs -- Number of accidents of the day
> ,sum(if(swrs7>0,1,0))as dr_swsgs -- Number of fatal accidents on that day
> ,sum(swrs7)as dr_swrs -- The death toll of the day
> ,sum(ssrs7)as dr_ssrs -- Number of injured on that day
> ,sum(zjccss)as dr_zjccss -- Direct property loss on that day
> from dwd.base_acd_file
> group by substr(sgfssj,1,10)
> )t1
> )tt1;
spark-sql> select * from dws.app_acd_mrjq;
Time taken: 0.271 seconds, Fetched 4966 row(s)
22/07/05 16:23:40 INFO thriftserver.SparkSQLCLIDriver: Time taken: 0.271 seconds, Fetched 4966 row(s)
spark-sql> select substr(fxjg,1,4) as fxjg,wfxw1 as wfxw,jtfs,dllx,xxly,wfdd,wfsj,cjbj,jllx from dwd.base_vio_force union all
> select substr(fxjg,1,4) as fxjg,wfxw2 as wfxw,jtfs,dllx,xxly,wfdd,wfsj,cjbj,jllx from dwd.base_vio_force union all
> select substr(fxjg,1,4) as fxjg,wfxw3 as wfxw,jtfs,dllx,xxly,wfdd,wfsj,cjbj,jllx from dwd.base_vio_force union all
> select substr(fxjg,1,4) as fxjg,wfxw4 as wfxw,jtfs,dllx,xxly,wfdd,wfsj,cjbj,jllx from dwd.base_vio_force union all
> select substr(fxjg,1,4) as fxjg,wfxw5 as wfxw,jtfs,dllx,xxly,wfdd,wfsj,cjbj,jllx from dwd.base_vio_force union all
> select substr(fxjg,1,4) as fxjg,wfxw,jtfs,dllx,xxly,wfdd,wfsj,'1' cjbj,jllx from dwd.base_vio_violation
> ;
Time taken: 4.433 seconds, Fetched 262227 row(s)
22/07/06 16:16:11 INFO thriftserver.SparkSQLCLIDriver: Time taken: 4.433 seconds, Fetched 262227 row(s)
spark-sql> select substr(fxjg,1,4)as fxjg
> ,wfxw
> ,jtfs
> ,dllx
> ,xxly
> ,wfdd
> ,wfsj
> ,cjbj
> ,jllx
> from dwd.base_vio_force
> lateral view explode(array(wfxw1,wfxw2,wfxw3,wfxw4,wfxw5))v as wfxw
> union
> select substr(fxjg,1,4) as fxjg,wfxw,jtfs,dllx,xxly,wfdd,wfsj,'1' cjbj,jllx from dwd.base_vio_violation
> ;
Time taken: 3.768 seconds, Fetched 129456 row(s)
22/07/06 16:24:40 INFO thriftserver.SparkSQLCLIDriver: Time taken: 3.768 seconds, Fetched 129456 row(s)
spark-sql> select *
> from(
> select substr(fxjg,1,4)as fxjg
> ,wfxw
> ,jtfs
> ,dllx
> ,xxly
> ,wfdd
> ,wfsj
> ,cjbj
> ,jllx
> from dwd.base_vio_force
> lateral view explode(array(wfxw1,wfxw2,wfxw3,wfxw4,wfxw5))v as wfxw
> union
> select substr(fxjg,1,4) as fxjg
> ,wfxw
> ,jtfs
> ,dllx
> ,xxly
> ,wfdd
> ,wfsj
> ,'1' cjbj
> ,jllx from dwd.base_vio_violation
> )t1 where t1.fxjg='5306' and t1.wfxw='1083B';
Time taken: 1.654 seconds, Fetched 443 row(s)
22/07/06 16:30:16 INFO thriftserver.SparkSQLCLIDriver: Time taken: 1.654 seconds, Fetched 443 row(s)
spark-sql> select *
> from(
> select substr(fxjg,1,4)as fxjg
> ,wfxw
> ,jtfs
> ,dllx
> ,xxly
> ,wfdd
> ,wfsj
> ,cjbj
> ,jllx
> from dwd.base_vio_force
> lateral view explode(array(wfxw1,wfxw2,wfxw3,wfxw4,wfxw5))v as wfxw
> union
> select substr(fxjg,1,4) as fxjg
> ,wfxw
> ,jtfs
> ,dllx
> ,xxly
> ,wfdd
> ,wfsj
> ,'1' cjbj
> ,jllx
> from dwd.base_vio_violation
> )t1 where t1.fxjg='5306' and t1.wfxw='1083B'
> order by t1.wfsj
> ;
Time taken: 2.812 seconds, Fetched 443 row(s)
22/07/06 16:33:18 INFO thriftserver.SparkSQLCLIDriver: Time taken: 2.812 seconds, Fetched 443 row(s)
spark-sql> select date_format('2020-10-16 01:36:24','yyyy-MM-dd');
spark-sql> select date_format('2020-10-16 01:36:24','yyyy/MM/dd');
spark-sql> select ttt1.tjrq
> ,ttt1.dr_wfs
> ,ttt1.jn_wfs
> ,ttt1.qntq_wfs
> ,NVL(round((abs(ttt1.dr_wfs-ttt1.qntq_wfs)/NVL(ttt1.qntq_wfs,1))*100,2),0) as tb
> from(
> select tt1.tjrq
> ,tt1.dr_wfs
> ,sum(tt1.dr_wfs)over (partition by year(tt1.tjrq))as jn_wfs
> ,lag(tt1.dr_wfs,1,1)over (partition by date_format(tt1.tjrq,'MM-dd')order by year(tt1.tjrq))as qntq_wfs
> from(
> select date_format(t1.wfsj,'yyyy-MM-dd')as tjrq
> ,count(1)as dr_wfs -- Illegal amount of the day
> from(
> select substr(fxjg,1,4)as fxjg
> ,wfxw
> ,jtfs
> ,dllx
> ,xxly
> ,wfdd
> ,wfsj
> ,cjbj
> ,jllx
> from dwd.base_vio_force
> lateral view explode(array(wfxw1,wfxw2,wfxw3,wfxw4,wfxw5))v as wfxw
> union
> select substr(fxjg,1,4) as fxjg
> ,wfxw
> ,jtfs
> ,dllx
> ,xxly
> ,wfdd
> ,wfsj
> ,'1' cjbj
> ,jllx
> from dwd.base_vio_violation
> )t1 where t1.wfxw is not null
> group by date_format(t1.wfsj,'yyyy-MM-dd')
> )tt1
> )ttt1
>
> ;
Time taken: 8.772 seconds, Fetched 1021 row(s)
22/07/06 16:57:47 INFO thriftserver.SparkSQLCLIDriver: Time taken: 8.772 seconds, Fetched 1021 row(s)
spark-sql> select ttt1.tjrq
> ,ttt1.dr_wfs
> ,ttt1.jn_wfs
> ,ttt1.qntq_wfs
> ,NVL(round((abs(ttt1.dr_wfs-ttt1.qntq_wfs)/NVL(ttt1.qntq_wfs,1))*100,2),0) as tb
> ,if(ttt1.dr_wfs>ttt1.qntq_wfs,' rising ',' falling ') as tbbj
> from(
> select tt1.tjrq
> ,tt1.dr_wfs
> ,sum(tt1.dr_wfs)over (partition by year(tt1.tjrq))as jn_wfs
> ,lag(tt1.dr_wfs,1,1)over (partition by date_format(tt1.tjrq,'MM-dd')order by year(tt1.tjrq))as qntq_wfs
> from(
> select date_format(t1.wfsj,'yyyy-MM-dd')as tjrq
> ,count(1)as dr_wfs -- Illegal amount of the day
> from(
> select substr(fxjg,1,4)as fxjg
> ,wfxw
> ,jtfs
> ,dllx
> ,xxly
> ,wfdd
> ,wfsj
> ,cjbj
> ,jllx
> from dwd.base_vio_force
> lateral view explode(array(wfxw1,wfxw2,wfxw3,wfxw4,wfxw5))v as wfxw
> union
> select substr(fxjg,1,4) as fxjg
> ,wfxw
> ,jtfs
> ,dllx
> ,xxly
> ,wfdd
> ,wfsj
> ,'1' cjbj
> ,jllx
> from dwd.base_vio_violation
> )t1 where t1.wfxw is not null
> group by date_format(t1.wfsj,'yyyy-MM-dd')
> )tt1
> )ttt1
> ;
Time taken: 5.995 seconds, Fetched 1021 row(s)
22/07/06 17:01:35 INFO thriftserver.SparkSQLCLIDriver: Time taken: 5.995 seconds, Fetched 1021 row(s)
边栏推荐
- Dynamic agent explanation (July 16, 2020)
- Redhat下安装fedora
- Matlab SEIR infectious disease model prediction
- Ros2 topic (03): the difference between ros1 and ros2 [01]
- Talk about the design and implementation logic of payment process
- 2021icpc Shanghai h.life is a game Kruskal reconstruction tree
- JMeter interface automated test read case, execute and write back result
- kubernetes的简单化数据存储StorageClass(建立和删除以及初步使用)
- Network security - Eternal Blue
- Matlab 信号处理【问答随笔·2】
猜你喜欢
leetcode-520. Detect capital letters -js
Wechat forum exchange applet system graduation design completion (7) Interim inspection report
re1攻防世界逆向
13、 System optimization
Talk about the design and implementation logic of payment process
在软件工程领域,搞科研的这十年!
海内外技术人们“看”音视频技术的未来
Wechat forum exchange applet system graduation design completion (1) development outline
When copying something from the USB flash disk, an error volume error is reported. Please run CHKDSK
MATLAB signal processing [Q & A essays · 2]
随机推荐
The 19th Zhejiang Provincial Collegiate Programming Contest VP记录+补题
Network security CSRF
Archlinux install MySQL
系统架构设计师备考经验分享:论文出题方向
ROS2专题(03):ROS1和ROS2的区别【01】
CAIP2021 初赛VP
When copying something from the USB flash disk, an error volume error is reported. Please run CHKDSK
UE4_UE5全景相机
Opencv scalar passes in three parameters, which can only be displayed in black, white and gray. Solve the problem
LDO稳压芯片-内部框图及选型参数
FreeLink开源呼叫中心设计思想
RE1 attack and defense world reverse
VS扩展工具笔记
Adrnoid Development Series (XXV): create various types of dialog boxes using alertdialog
十三、系统优化
Installing spss25
JS get the key and value of the object
Unity3d Learning Notes 6 - GPU instantiation (1)
Mysql索引优化实战二
Spark 离线开发框架设计与实现