hive
共享單車模擬數(shù)據(jù)分析
要求如下
庫名:hongyaa
表名:bike
?
字段:
持續(xù)時(shí)間 duration int,
開始時(shí)間 startdate timestamp,(注意時(shí)間戳在分析中的細(xì)節(jié))
還車時(shí)間 enddate timestamp,
開始地編號 startnum int,
開始地名稱 startstation string,
還車地編號 endnum int,
還車地名稱 endstation string,
自行車編號 bikenum string,
用戶類型 type string,(會員/臨時(shí)會員)
?
?
以上面的字段創(chuàng)建一個(gè)名為bike的表,要求每一列以“制表符”為分割。
(答案為白色字體,下同)
create table bike (duration int,startdate timestamp,enddate timestamp,startnum int,startstation string,endnum int,endstation string,bikenum string,type string)
row format delimited fields terminated by ',';
?
檢查表的字段:desc?bike;(建表是一個(gè)得分點(diǎn),表字段錯了后面全做不了)
導(dǎo)入數(shù)據(jù):load data local inpath '/root/bike.txt' into table bike;
?
啟用本地計(jì)算模式,此舉可縮短計(jì)算時(shí)間,平時(shí)可以對比試試看,比賽時(shí)建議使用
>set hive.exec.mode.local.auto=true;
?
數(shù)據(jù)分析(不分大小寫,回車可過行,結(jié)束加分號)
1.一共調(diào)查了多少輛單車?寫入“/root/test001/“用分號隔開 ??#3191
Insert?overwrite local directory?‘/root/test001/’
Row format delimited?fields?terminated?by?‘;’
select count(distinct(bikenum)) from bike;
?
?
2.?會員在全部受訪者中占比是多少? #0.9
select round((t1.a/t2.b),2) from (select count(*) a from bike where type='Member') t1 join (select count(*) b from bike) t2;
?
另一種方法:分開兩次算,先算會員數(shù)量,再算比例
Select count(*) a
From bike;
?
Select count(*) b?
from bike
where type='Member';
?
Select round((a/b),2);?type=’Member’; #38220
Select (38220/count(*),2) from bike; #0.9
3.用車最多的是哪個(gè)地區(qū)?(以開始地點(diǎn)計(jì)算)#Columbus Circle / Union Station
select startstation,count(*) as a
from bike
group by startstation
order by a desc limit 1;
?
4.騎行時(shí)間最長是多少?的是哪輛車(車號)? #84876226 W23232
select duration,bikenum
from bike
order by duration desc limit 1;
?
5.這些單車平均騎行時(shí)間?(單位毫秒) #785938.47 (ms)
select avg(duration)
from bike;
?
6.這些單車平均騎行時(shí)間?(單位分鐘) #13.10
select avg(duration/60000) //1分鐘等于60000毫秒
from bike;
?
7.一月一日一共有多少輛車在工作? #1570
select count(distinct bikenum)
from bike
where month(startdate)=1 and day(startdate)=1;
?
8.正式會員最少的地區(qū)是哪個(gè)地區(qū)? #6035 Warehouse
select startstation,count(*) a
from bike
where type='Member'
group by startstation
order by a desc limit 1;
?
9.哪一天上班早高峰(6點(diǎn)-9點(diǎn))用車量最大,并計(jì)算該段時(shí)間用車頻次,用制表符分開。
row format delimited fields terminated by '\t'
select day(startdate) as a ,count(*) as b
from bike
where hour(stratedate) in (6,7,8)
group by a
order by b desc limit 1;
?
10.找出騎行時(shí)間最短的車號;w 20752
select min(duration) from bike;
select bikenum from bike
where duration='60777';
?
另一種方法:select bikenum from bike?where duration in (select min(duration) from bike)
11.找出單車騎行時(shí)間大于平均騎行時(shí)間的車號及其騎行時(shí)間,使用','分隔,將結(jié)果保存在'/root/test011'中;
select avg(duration) from bike; 785938
?
insert overwrite local directory '/root/test011'
row format delimited fields terminated by ','
select bikenum,duration
from bike
where duration>'785938' ;
?
12.計(jì)算出在一月8日工作的車輛數(shù),將結(jié)果保存在'/root/test012'中;952
insert overwrite local directory '/root/test012' ??????????????????1920
row format delimited fields terminated by ','
select count(distinct(bikenum))
from bike
where month =’1’?and day(startdate)='8'
?
?
13.找出正式會員最少的地區(qū)中臨時(shí)會員的數(shù)量,使用','分隔,將結(jié)果保存在'/root/test013'中;
select startstation,count(*) a
from bike
where type='Member' group by startstation ?
order by a desc limit 1; //6035 Warehouse
?
insert overwrite local directory '/root/test013'
select count(*) from bike
where type='Casual' and startstation='Warehouse';
?
?
14.找出1月9日下班高峰(17點(diǎn)-20點(diǎn))用車數(shù)最多的地區(qū),用','分隔,降序排序; #1st & M St NE,10
select startstation,count(*) a
from bike
where month=’1’?and day(startdate)='9' and hour(startdate) in (17,18,19,20) group by startstation order by a desc limit 1;???
?
Columbus Circle / Union Station 54
可視化
1.?繪出2017年1月1日到1月6日的用車情況(數(shù)量)折線圖。
標(biāo)題為:”2017年1月1日到1月6日會員與非會員用車情況“
標(biāo)簽依次為會員,非會員
橫坐標(biāo)為1日...6日
以開始時(shí)間為準(zhǔn)
?
select type,count(*) from bike where ?day(startdate)='1' group by type;
Casual 1580
Member 2484
select type,count(*) from bike where ?day(startdate)='2' group by type;
Casual 181
Member 1459
select type,count(*) from bike where ?day(startdate)='3' group by type;
Casual 254
Member 3520
select type,count(*) from bike where ?day(startdate)='4' group by type;
Casual 748
Member 6438
select type,count(*) from bike where ?day(startdate)='5' group by type;
Casual 402
Member 5814
select type,count(*) from bike where ?day(startdate)='6' group by type;
Casual 309
Member 5263
?
???????option = {
????????????title:{
????????????????text:'2017一月1日到一月6日會員與非會員用車情況'
????????????????},
????????????xAxis:{
????????????????type:'category',
????????????????data:['1日','2日','3日','4日','5日','6日']
????????????????},
????????????legend:{
????????????????data:['會員','非會員'],
????????????????x:'right',
????????????????},
????????????yAxis:{
????????????????type:'value',
????????????????},
????????????series:[
????????????????{
????????????????????name:'會員',
????????????????????type:'line',
????????????????????data:[2484,1459,3520,6438,5814,5263]
????????????????},
????????????????{
????????????????????name: '非會員',
????????????????????type: 'line',
????????????????????data: [1580,181,254,748,402,309]
????????????????}]
????????};
?
?
?
?
2.各地會員數(shù)量前3的地區(qū)及數(shù)量和全體用戶類型的雙餅圖
Select startstation,count(*) a
From bike
Where type=’Member’
Group by startstation
Order by a desc limit 3;
?
Select count(*) a
From bike
Where type=’Member’;
?
Select count(*) b
From bike
Where type=’Casual’;
?
Select round((a/b),5);
?
option={
????title:{
????????text:'會員類別及會員數(shù)量前五的地區(qū)比例圖',
????????x:'center'
????},
????tooltip:{
????????trigger:'item',
????????formatter:"{a}<br/>:{c}(s0sssss00s%)"
????},
????legend:{
????????orient:'vertical',
?????????x:'left',
????????data:['Columbus Circle / \nUnion Station','15th & P \nSt NW','Thomas \nCircle','New Hampshire Ave &\n T St NW','Massachusetts Ave &\n Dupont Circle NW']
????},
????series:[
????????{
????????????name:'用戶類別',
????????????type:'pie',
????????????selectdMode:'single',
????????????radius:[0,'30%'],
????????????data:[
????????????????{value:4185,name:'臨時(shí)會員'},
???????????????{value:38220,name:'會員',color:'bule'}
????????????]
????????},
????????{
????????????name:'地區(qū)',
????????????type:'pie',
????????????radius:['40%','55%'],
????????????data:[
????????????????{value:1029,name:'Columbus Circle / \nUnion Station'},
???????????????{value:541,name:'15th & P \nSt NW'},
????????????????{value:535,name:'Thomas \nCircle'},
???????????????{value:527,name:'New Hampshire Ave &\n T St NW'},
????????????????{value:480,name:'Massachusetts Ave &\n Dupont Circle NW'}
????????????????]
????????}
????]
};
?
持續(xù)時(shí)間 duration int,
開始時(shí)間 startdate timestamp,(注意時(shí)間戳在分析中的細(xì)節(jié))
還車時(shí)間 enddate timestamp,
開始地編號 startnum int,
開始地名稱 startstation string,
還車地編號 endnum int,
還車地名稱 endstation string,
自行車編號 bikenum string,
用戶類型 type string,(會員/臨時(shí)會員)
?
3.以地點(diǎn)為橫坐標(biāo),
繪出各地會員數(shù)量前5的地區(qū)及數(shù)量的柱狀圖,
title='會員的數(shù)量TOP5的地區(qū)'
?
?
Select startstation,count(*) a
From bike
Group by startstation
Order by a desc limit 5;
?
Columbus Circle / Union Station 1029
15th & P St NW 541
Thomas Circle 535
New Hampshire Ave & T St NW 527
Massachusetts Ave & Dupont Circle NW 480
?
????????option = {
????????????title:{
????????????????text:'會員數(shù)量前5的地區(qū)及數(shù)量',
????????????????x:'center'
????????????},
????????????color: ['#388599'],
????????????tooltip : {
????????????????trigger: 'axis'
????????????},
????????????grid: {
????????????????left: '0%',
????????????????right: '0%',
????????????????bottom: '0%',
????????????????containLabel: true
????????????},
????????????xAxis : [
????????????????{
????????????????????text:'地區(qū)',
????????????????????type : 'category',
????????????????????data : ['Columbus Circle / \nUnion Station', '15th & \nP St NW',
????????????????????'Thomas\n Circle', 'New Hampshire Ave\n & T St NW',
????????????????????'Massachusetts Ave &\n Dupont Circle NW'],
????????????????????axisTick: {
????????????????????????alignWithLabel: true
????????????????????}
????????????????}
????????????],
????????????yAxis : [
????????????????{
????????????????????type : 'value'
????????????????}
????????????],
????????????series : [
????????????????{
????????????????????name:'單車使用頻次',
????????????????????type:'bar',
????????????????????barWidth: '50%',
????????????????????data:[1029, 541, 535, 527, 480]
????????????????}
????????????]
????????};
?
?
2019智警杯模擬數(shù)據(jù)分析
要求如下
庫名:hongya
表名:final
?
字段:
案件編號 id int,
案件狀態(tài) state string,
案件副類別 class string,
損失金額 loss int,
損失程度 degree string,
作案手法 mode string,
案件來源 source string,
案發(fā)事件上限uppertime timestamp,
案發(fā)事件下限lowertime timestamp,
案發(fā)地點(diǎn) place string,
受理單位 accept_unit string,
受理時(shí)間 accept_time timestamp,
報(bào)案時(shí)間 take_time timestamp,
警員 ?police string,
破案時(shí)間 break_time timestamp
?
?
以上面的字段創(chuàng)建一個(gè)名為final的表,要求每一列以“制表符”為分割。
(答案為白色字體,下同)
create table final(
id int,state string,class string,loss int,
degree string,mode string,source string,
uppertime timestamp,lowertime timestamp,
place string,accept_unit string,
accept_time timestamp,take_time timestamp,
police string,break_time timestamp)
row format delimited fields terminated by '\t';
?
檢查表的字段:desc?final;(建表是一個(gè)得分點(diǎn),表字段錯了后面全做不了)
導(dǎo)入數(shù)據(jù):load data inpath '目錄/xxx.txt' into table final;
?
啟用本地計(jì)算模式,此舉可縮短計(jì)算時(shí)間,平時(shí)可以對比試試看,比賽時(shí)建議使用
>set hive.exec.mode.local.auto=true;
數(shù)據(jù)分析(不分大小寫,回車可過行,結(jié)束加分號)
1.統(tǒng)計(jì)2017年3月份(以發(fā)案時(shí)間為準(zhǔn))的經(jīng)濟(jì)損失總額,將結(jié)果寫入到/root/test001/中,要求使用 “制表符”作為聲明文件分隔符;
insert owerwrite local directory?‘/root/test001/’
row?format delimited fields terminated by ‘\t’
select?sum(loss)
from final
where year(take_time) = 2017 and month(take_time) = 3;
?
?
2.找出經(jīng)濟(jì)損失最多的案件副類別,并給出該案件副類別對應(yīng)的損失總額,將結(jié)果寫入到/root/test002/中,要求使用 “制表符”作為聲明文件分隔符。
Insert overwrite local directory ‘/root/test002/’
Row format delimited fields terminated by ‘\t’
Select class,sum(loss) total
from final
group by class
order by total desc limit?1;
?
?
3.統(tǒng)計(jì)2016年03月份發(fā)生案件總數(shù),將結(jié)果寫入到/root/test003/中,要求使用 “制表符”作為聲明文件分隔符。
Insert overwrite local directory ’/root/test003/’
Row format delimited fields terminated by’\t’
Select count(*) from final where year(tabe_time)=2016 and mouth(take_time)=3;
?
?
4.在損失度為“特別巨大”的案件中,找出發(fā)生頻次最高的案件副類別并統(tǒng)計(jì)其發(fā)生頻次,將結(jié)果寫入到/root/test004/中,要求使用 “制表符”作為聲明文件分隔符.
Insert overwrite local directory ’/root/test004/’
Row format delimited fields terminated by’\t’
Select class,count(*) total
from final
where degree=’特別巨大’
Group by class
order by total desc limit 1;
?
?
5.列出詐騙最高發(fā)的地區(qū)及其對應(yīng)的損失金額TOP3,將結(jié)果寫入到/root/test005/中,要求使用 “制表符”作為聲明文件分隔符;
Insert overwrite local directory ’/root/test005/’
Row format delimited fields terminated by’\t’
Select place,sum(loss) total
from final
where class like ‘%詐騙%’
group by place
order by total limit 3;
?
?
6.“短信詐騙”的發(fā)案時(shí)間平均為多久(即發(fā)案時(shí)間的下限(天)-發(fā)案時(shí)間的上限(天)),將結(jié)果寫入到/root/test006/中,要求使用 “制表符”作為聲明文件分隔符;
DATEDIFF() 函數(shù)返回兩個(gè)日期之間的時(shí)間
語法格式:DATEDIFF(datepart,startdate,enddate)
Insert overwrite local directory ’/root/test006/’
Row format delimited fields terminated by’\t’
Select?int(avg(datadiff(day,lowertime,uppertime)))
from final
Where class = ‘短信詐騙’;
?
?
7.?列出2016年春季的經(jīng)濟(jì)損失總額,將結(jié)果寫入到/root/test007/中,要求使用 “制表符”作為聲明文件分隔符;
Insert overwrite local directory ’/root/test007/’
Row format delimited fields terminated by’\t’
Select?sum(loss) from final
where year(take_time)=2016 and month(take_time)=(1,2,3);
?
8.列出“深夜”時(shí)段受理案件最多的派出所及其受理案件數(shù)目。
(00-07為深夜,08-12為上午,13-19為下午,20-23為晚上)
格式:對于結(jié)果中的二維數(shù)據(jù),要求使用?“制表符”作為聲明文件
分隔符。
復(fù)合排列:按照受理案件數(shù)據(jù)進(jìn)行降序排列;
Row format delimited fields terminated by’\t’
Select accept_unit,count(*) total
from final
where hour(accept_time) in (0,1,2,3,4,5,6,7)
Group by accept_unit
Order by total desc limit 1;
?
9.列出網(wǎng)絡(luò)詐騙中案發(fā)頻次最高的作案手法top5及其對應(yīng)案發(fā)次數(shù);
格式:對于結(jié)果中的二維數(shù)據(jù),要求使用?“制表符”作為聲明文件分隔符。
復(fù)合排列:按照案發(fā)次數(shù)進(jìn)行降序排列;
Select mode,count(*) tatal from final
Where class=’網(wǎng)絡(luò)詐騙’
Group by mode
Order by total desc limit 5;
?
;列出2019年破獲案件總金額最高的接警員(按姓氏)top10及其破獲總金額。
格式:對于結(jié)果中的二維數(shù)據(jù),要求使用“制表符”作為聲明文件分隔符。
復(fù)合排列:按照金額數(shù)目進(jìn)行降序排列;
?
Row format?delimited fields terminated by ‘\t’
Select police,sum(loss) total from final
Where state=’破案’ and year(break_time)=2019
Group by police
Order by total desc limit 10;
?
?
11.統(tǒng)計(jì)在A城案件中的各案件副類別發(fā)生頻次。
格式:對于結(jié)果中的二維數(shù)據(jù),要求使用“制表符”作為聲明文件分隔符。
復(fù)合排列:按照類別頻次進(jìn)行降序排列;
Select class,count(*) total from final
Where take_place?like ’A城%’
Group by class
Order by total desc;
?
12.在損失金額超過18萬的案件中,找出受理案件最多的派出所top5及其對應(yīng)
受理案件數(shù)目。
格式:對于結(jié)果中的二維數(shù)據(jù),要求使用?“制表符”作為聲明文件分隔符。
復(fù)合排列:先按照受理案件數(shù)目進(jìn)行降序排列,再按照派出所名稱升序排列;
?
Select accept_unit,count(*) cases from final
Where loss > 180000
Group by accept_unit
Order by cases desc,accept_unit limit 5;
?
?
13.統(tǒng)計(jì)出C城深夜時(shí)段發(fā)生案件總次數(shù)
?
Select count(*) from final
Where hour(take_time) in (0,1,2,3,4,5,6,7) and place=’C城’;
?
14.統(tǒng)計(jì)出2016年下半年破案數(shù)top10的警察及其破案數(shù)
?
Select?police,count(*) total from final
Where state=’破案’?and year(break_time)=2016 and month(break_time) in (6,7,8,9,10,11,12)
Group by police
Order by total desc limit 10;
?
15.統(tǒng)計(jì)近年來損失程度較大的犯罪案件,顯示年份和數(shù)量和經(jīng)濟(jì)損失,按年份排序
?
Select?year(take_time) as?a,count(*),sum(loss) from final
Where degree=’較大’
Group by a
Order by a;
?
16.統(tǒng)計(jì)所有詐騙手法,次數(shù)及金額
?
Select mode,count(*),sum(loss)
from final
Group by mode;
?
T17.統(tǒng)計(jì)2018年所有城市的破案率,保留兩位小數(shù) 【17,18,19,20有更好的方法(但是我不會。。。)】
?
①Select count(*) from final where year(take_time)=2018 and year(break_time)=2018;
②Select?count(*) from final
where year(take_time)=2018 and year(break_time)=2018 and state=’破案’;
③select round(①/②,2);
?
?
18.2019年發(fā)生最多的案件副類別的破案率?#網(wǎng)絡(luò)詐騙 0.77
select class,count(*) as total from final where year(take_time)=2019 group by class order by total desc limit 1; ???#網(wǎng)絡(luò)詐騙 244
select count(*)/244 from final where year(take_time)=2019 and year(break_time)=2019 and class='網(wǎng)絡(luò)詐騙';
?
?
19.比網(wǎng)絡(luò)詐騙破案率高的案件副類別有什么? #電話詐騙,短信詐騙
select class,count(*) as total from final where state='破案' group by class order by total desc;
select class,count(*) as total from final group by class order by total desc;
select (1258/1688); #0.75
select (163/208); #0.78
select (83/104); #0.80
?
?
?
20.各民警在2017年8月的電信詐騙破案率?
select count(*)?a from final where year(take_time)=2017 and month(take_time)=8 and year(break_time)=2017 and month(break_time)=8?and class=’電信詐騙’;
?
select police,count(*) b from final where year(take_time)=2017 and month(take_time)=8 and year(break_time)=2017 and month(break_time)=8 and police like '%警官'?and class=’電信詐騙’?group by police?order by b;
Select (a/b)
可視化
1.繪出所有案件的損失程度比例圖;(餅圖)
要求:1.圖形類別為餅狀圖;
title=‘案件損失程度比例圖’;
標(biāo)簽legend依次為:較大,巨大,特別巨大
series.name=‘損失程度’;
?
insert overwrite local directory '/root/test101/'
row format delimited fields terminated by '\t'
select count(*) from final;
select round(count(*)/2000,2)*100 from final where degree='較大';#70
select round(count(*)/2000,2)*100 from final where degree='巨大';#22
select round(count(*)/2000,2)*100 from final where degree='特別巨大';#8
?
option = {
? ? title: {
? ? ? ? text: '案件損失程度比例圖',
? ? ? ? x: 'center' //位置居中
? ? },
? ? tooltip: {
? ? ? ? trigger: 'item', //觸發(fā)鍵,把鼠標(biāo)放在圖形上面觸發(fā)
formatter:"{a}<br/>:{c}(s0sssss00s%)"
? ? },
? ? legend: {
? ? ? ? orient: 'vertical', //垂直放圖例
? ? ? ? x: 'left', //圖例放在左邊
data:['較大','巨大','特別巨大']
? ? },
? ? series: [
? ? ? ? {
? ? ? ? ? ? name: '損失程度',
? ? ? ? ? ? type: 'pie',
selectdMode:'single',
? ? ? ? ? ? data: [
? ? ? ? ? ? ? ? {value: 70, name: '較大'},
? ? ? ? ? ? ? ? {value: 22, name: '巨大'},
? ? ? ? ? ? ? ? {value: 8, name: '特別巨大'}
? ? ? ? ? ? ],
? ? ? ? }
? ? ]}
?
?
2.繪出所有案件的作案手法比例圖;(雙餅圖)
要求:
title=’ 案件副類別及作案手法比例圖’;
legend標(biāo)簽依次為'冒充熟人','網(wǎng)絡(luò)貸款','購物釣魚網(wǎng)站
','網(wǎng)絡(luò)購物','銀行卡案件','虛擬物品','涉案轉(zhuǎn)賬','網(wǎng)絡(luò)預(yù)
測彩票';
series.name=‘作案手法’;
圖形類型必須為餅狀圖;
?
insert overwrite local directory '/root/test102/'
row format delimited fields terminated by '\t'
select mode,count(*) from final
group by mode;
?
option = {
? ? title: {
? ? ? ? text: '某站點(diǎn)用戶訪問來源',
? ? ? ? x: 'center' //位置居中
? ? },
? ? tooltip: {
? ? ? ? trigger: 'item', //觸發(fā)鍵,把鼠標(biāo)放在圖形上面觸發(fā)
formatter:"{a}<br/>:{c}(s0sssss00s%)"
? ? },
? ? legend: {
? ? ? ? orient: 'vertical', //垂直放圖例
? ? ? ? x: 'left', //圖例放在左邊
data:['1','2']
? ? },
? ? series: [
? ? ? ? {
? ? ? ? ? ? name: '名稱',
? ? ? ? ? ? type: 'pie',
selectdMode:'single',
? ? ? ? ? ? radius: '30%',
? ? ? ? ? ? data: [
? ? ? ? ? ? ? ? {value: 1048, name: '搜索引擎'},
? ? ? ? ? ? ? ? {value: 735, name: '直接訪問'},
? ? ? ? ? ? ? ? {value: 580, name: '郵件營銷'},
? ? ? ? ? ? ? ? {value: 484, name: '聯(lián)盟廣告'},
? ? ? ? ? ? ? ? {value: 300, name: '視頻廣告'}
? ? ? ? ? ? ],
? ? ? ? }
{
????????????name:'地區(qū)',
????????????type:'pie',
????????????radius:['40%','55%'],
????????????data:[
????????? ??? {value: 1048, name: '搜索引擎'},
? ? ? ? ? ? ? ? {value: 735, name: '直接訪問'},
? ? ? ? ? ? ? ? {value: 580, name: '郵件營銷'},
? ? ? ? ? ? ? ? {value: 484, name: '聯(lián)盟廣告'},
? ? ? ? ? ? ? ? {value: 300, name: '視頻廣告'}
????????????????]
????????}
? ? ]
};
?
?
?
3.繪出2015-2019年每年的案件副類別發(fā)生頻次隨年份的變化圖;(折線圖)
要求:1.圖形類別為折線圖;
title=‘2015年至2019年各案件副類別頻次圖’;
標(biāo)簽依次為電話詐騙,短信詐騙,網(wǎng)絡(luò)詐騙;
橫坐標(biāo)時(shí)間順序依次為2015年,2016年,2017年,2018年,2019年;
?
select class,count(*) from final where year(take_time)='2015'
group by class ;
電話詐騙 58
短信詐騙 29
網(wǎng)絡(luò)詐騙 368
select class,count(*) from final where year(take_time)='2016'
group by class ;
電話詐騙 53
短信詐騙 23
網(wǎng)絡(luò)詐騙 328
select class,count(*) from final where year(take_time)='2017'
group by class ;
電話詐騙 39
短信詐騙 19
網(wǎng)絡(luò)詐騙 367
select class,count(*) from final where year(take_time)='2018'
group by class ;
電話詐騙 30
短信詐騙 24
網(wǎng)絡(luò)詐騙 381
select class,count(*) from final where year(take_time)='2019'
group by class ;
電話詐騙 28
短信詐騙 9
網(wǎng)絡(luò)詐騙 244
option = {
? ? ? ? title : {
? ? ? ? ? ? text: '2015年至2019年各案件副類別頻次圖',
x:'center'
? ? ? ? ? ? ?},
? ? ? ? legend: {
? ? ? ? ? ? data:['電話詐騙','網(wǎng)絡(luò)詐騙','短信詐騙'], //標(biāo)簽
?????????????x:'right',
?????????????orient: 'vertical', //垂直放圖例
? ? ? ? },
? ? ? ? xAxis : [
? ? ? ? ? ? {
? ? ? ? ? ? ? ? type : 'category', //類目
? ? ? ? ? ? ? ? data : ['2015年','2016年','2017年','2018年','2019年']
? ? ? ? ? ? }
? ? ? ? ],
? ? ? ? yAxis : [
? ? ? ? ? ? {
? ? ? ? ? ? ? ? type : 'value', //數(shù)值軸
? ? ? ? ? ? ?}
? ? ? ? ],
? ? ? ? series : [
? ? ?? ? ? {
? ? ? ? ? ? ? ? name:'電話詐騙',
? ? ? ? ? ? ? ? type:'line', //圖形類型—折線圖
? ? ? ? ? ? ? ? data:[58,53,38,30,28]
? ? ? ? ? ? },
? ???????{
? ? ? ? ? ? ? ? name:'短信詐騙',
? ? ? ? ? ? ? ? type:'line', //圖形類型—折線圖
? ? ? ? ? ? ? ? data:[29,23,19,24,9]
? ? ? ? ? ? },
????????{
? ? ? ? ? ? ? ? name:'網(wǎng)絡(luò)詐騙',
? ? ? ? ? ? ? ? type:'line', //圖形類型—折線圖
? ? ? ? ? ? ? ? data:[368,328,367,381,244]
? ? ? ? ? ? },
? ? ? ? ]
? ? };
?
?
4.2016年與2018年各案件副類別破案率對比圖(柱狀圖)
要求:1.圖形類別為柱狀圖;
title=‘2016年與2018年各案件副類別破案率對比圖’;
標(biāo)簽依次為'2016年','2018年';
y軸為類目軸,其坐標(biāo)時(shí)間順序依次為電話詐騙破案率,短信詐騙破案率,網(wǎng)絡(luò)詐騙破案率;
round精度為小數(shù)點(diǎn)后2位;
?