当前位置:网站首页>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)
边栏推荐
- 树后台数据存储(採用webmethod)[通俗易懂]
- Network security -burpsuit
- Description of longitude and latitude PLT file format
- USB (十七)2022-04-15
- Tree background data storage (using webmethod) [easy to understand]
- Wechat forum exchange applet system graduation design (2) applet function
- Conversion between commonsmultipartfile and file
- Opencv scalar passes in three parameters, which can only be displayed in black, white and gray. Solve the problem
- Specific method example of V20 frequency converter manual automatic switching (local remote switching)
- 高级程序员必知必会,一文详解MySQL主从同步原理,推荐收藏
猜你喜欢
Wechat forum exchange applet system graduation design completion (4) opening report
二叉树(Binary Tree)
Wechat forum exchange applet system graduation design completion (7) Interim inspection report
Wechat forum exchange applet system graduation design completion (6) opening defense ppt
Install a new version of idea. Double click it to open it
Wechat forum exchange applet system graduation design (2) applet function
Technology at home and abroad people "see" the future of audio and video technology
Solve the problem of duplicate request resource paths /o2o/shopadmin/o2o/shopadmin/getproductbyid
Wechat forum exchange applet system graduation design (3) background function
Wechat forum exchange applet system graduation design (5) assignment
随机推荐
Quelles sont les similitudes et les différences entre les communautés intelligentes et les villes intelligentes?
POJ2392 SpaceElevator [DP]
ROS2专题(03):ROS1和ROS2的区别【02】
漏洞复现----49、Apache Airflow 身份验证绕过 (CVE-2020-17526)
Unity3d Learning Notes 6 - GPU instantiation (1)
Binary tree
Cloud native data warehouse analyticdb MySQL user manual
Network security sqlmap and DVWA explosion
解决:信息中插入avi格式的视频时,提示“unsupported video format”
云原生正在吞噬一切,开发者该如何应对?
USB (十八)2022-04-17
JS get the key and value of the object
Introduction to redis and jedis and redis things
做自媒体视频剪辑怎么赚钱呢?
RE1 attack and defense world reverse
14、 Two methods of database export and import
网络安全-burpsuit
UE4_UE5全景相机
给出一个数组,如 [7864, 284, 347, 7732, 8498],现在需要将数组中的数字拼接起来,返回「最大的可能拼出的数字」
Add data analysis tools in Excel