首先,在mysql里創(chuàng)建表的字段:
然后將文件導(dǎo)入mysql:
set global local_infile = 1;
load data local infile '/users/fangluping/desktop/數(shù)據(jù)底表202001.csv'
into table 湖山賦
fields terminated by ','
ignore 1 lines;
select * from 湖山賦;
導(dǎo)入成功:
我們先制作一張樓棟分析表:
#樓棟分析表
select distinct a.樓棟, b.業(yè)態(tài), c.是否取證, d.是否認(rèn)購,e.是否開盤,f.是否簽約,g.是否網(wǎng)簽,h.是否款齊,
建筑面積,套數(shù), 總價,單價,已收房款,實收現(xiàn)金,按揭金額
from (
select distinct 樓棟,
sum(預(yù)測建筑面積) 建筑面積,
count(房源名稱) 套數(shù),
sum(成交總價)/sum(預(yù)測建筑面積) 單價,
sum(成交總價) 總價,
sum(成交總價已收房款) 已收房款,
sum(實收房款現(xiàn)金) 實收現(xiàn)金,
sum(按揭實收金額) 按揭金額
from 湖山賦
group by 樓棟) a left join (select distinct 樓棟, 業(yè)態(tài) from 湖山賦) b
on a.樓棟=b.樓棟
left join (select distinct 樓棟,
if(預(yù)售許可證取證日期=0,'未取證','已取證') as 是否取證
from 湖山賦) c on a.樓棟=c.樓棟
left join (select distinct 樓棟,
if(認(rèn)購日期=0,'未認(rèn)購','已認(rèn)購') as 是否認(rèn)購
from 湖山賦) d on a.樓棟=d.樓棟
left join (select distinct 樓棟,
if(推盤日期=0,'未開盤','已開盤') as 是否開盤
from 湖山賦) e on a.樓棟=e.樓棟
left join (select distinct 樓棟,
if(簽約日期=0,'未簽約','已簽約') as 是否簽約
from 湖山賦) f on a.樓棟=f.樓棟
left join (select distinct 樓棟,
if(網(wǎng)簽日期=0,'未網(wǎng)簽','已網(wǎng)簽') as 是否網(wǎng)簽
from 湖山賦) g on a.樓棟=g.樓棟
left join (select distinct 樓棟,
if(現(xiàn)金款齊日期=0,'未款齊','已款齊') as 是否款齊
from 湖山賦) h on a.樓棟=h.樓棟;
得到如圖所示報表:
接著我們從付款方式的維度進(jìn)行分析:
#付款方式分析表
select 付款方式名稱,
count(房源名稱),
count(房源名稱)/(select count(房源名稱) from 湖山賦 where 付款方式名稱 !='無') as 房源占比,
sum(預(yù)測建筑面積),
sum(預(yù)測建筑面積)/(select sum(預(yù)測建筑面積) from 湖山賦 where 付款方式名稱 !='無') as 建筑面積占比,
sum(成交總價已收房款),
sum(成交總價已收房款)/(select sum(成交總價已收房款) from 湖山賦 where 付款方式名稱 !='無') as 已收房款占比,
sum(實收房款現(xiàn)金),
sum(實收房款現(xiàn)金)/(select sum(實收房款現(xiàn)金) from 湖山賦 where 付款方式名稱 !='無') as 實收房款現(xiàn)金占比,
sum(按揭實收金額),
sum(按揭實收金額)/(select sum(按揭實收金額) from 湖山賦 where 付款方式名稱 !='無') as 按揭實收金額占比
from 湖山賦
group by 付款方式名稱
having 付款方式名稱 != '無';
得到付款方式報表:
最后我們從業(yè)態(tài)的維度進(jìn)行分析:
#業(yè)態(tài)分析表
select distinct 業(yè)態(tài),
count(房源名稱),
count(房源名稱)/(select count(房源名稱) from 湖山賦 where 付款方式名稱 !='無') as 房源占比,
sum(預(yù)測建筑面積),
sum(預(yù)測建筑面積)/(select sum(預(yù)測建筑面積) from 湖山賦 where 付款方式名稱 !='無') as 建筑面積占比,
sum(成交總價已收房款),
sum(成交總價已收房款)/(select sum(成交總價已收房款) from 湖山賦 where 付款方式名稱 !='無') as 已收房款占比,
sum(實收房款現(xiàn)金),
sum(實收房款現(xiàn)金)/(select sum(實收房款現(xiàn)金) from 湖山賦 where 付款方式名稱 !='無') as 實收房款現(xiàn)金占比,
sum(按揭實收金額),
sum(按揭實收金額)/(select sum(按揭實收金額) from 湖山賦 where 付款方式名稱 !='無') as 按揭實收金額占比
from 湖山賦
group by 業(yè)態(tài);
得到報表:
本文摘自 :https://blog.51cto.com/u