首先,在mysql里创建表的字段:
然后将文件导入mysql:
set global local_infile = 1;
load data local infile '/users/fangluping/desktop/数据底表202001.csv'
into table 湖山赋
fields terminated by ','
ignore 1 lines;
select * from 湖山赋;
导入成功:
我们先制作一张楼栋分析表:
#楼栋分析表
select distinct a.楼栋, b.业态, c.是否取证, d.是否认购,e.是否开盘,f.是否签约,g.是否网签,h.是否款齐,
建筑面积,套数, 总价,单价,已收房款,实收现金,按揭金额
from (
select distinct 楼栋,
sum(预测建筑面积) 建筑面积,
count(房源名称) 套数,
sum(成交总价)/sum(预测建筑面积) 单价,
sum(成交总价) 总价,
sum(成交总价已收房款) 已收房款,
sum(实收房款现金) 实收现金,
sum(按揭实收金额) 按揭金额
from 湖山赋
group by 楼栋) a left join (select distinct 楼栋, 业态 from 湖山赋) b
on a.楼栋=b.楼栋
left join (select distinct 楼栋,
if(预售许可证取证日期=0,'未取证','已取证') as 是否取证
from 湖山赋) c on a.楼栋=c.楼栋
left join (select distinct 楼栋,
if(认购日期=0,'未认购','已认购') as 是否认购
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(网签日期=0,'未网签','已网签') as 是否网签
from 湖山赋) g on a.楼栋=g.楼栋
left join (select distinct 楼栋,
if(现金款齐日期=0,'未款齐','已款齐') as 是否款齐
from 湖山赋) h on a.楼栋=h.楼栋;
得到如图所示报表:
接着我们从付款方式的维度进行分析:
#付款方式分析表
select 付款方式名称,
count(房源名称),
count(房源名称)/(select count(房源名称) from 湖山赋 where 付款方式名称 !='无') as 房源占比,
sum(预测建筑面积),
sum(预测建筑面积)/(select sum(预测建筑面积) from 湖山赋 where 付款方式名称 !='无') as 建筑面积占比,
sum(成交总价已收房款),
sum(成交总价已收房款)/(select sum(成交总价已收房款) from 湖山赋 where 付款方式名称 !='无') as 已收房款占比,
sum(实收房款现金),
sum(实收房款现金)/(select sum(实收房款现金) from 湖山赋 where 付款方式名称 !='无') as 实收房款现金占比,
sum(按揭实收金额),
sum(按揭实收金额)/(select sum(按揭实收金额) from 湖山赋 where 付款方式名称 !='无') as 按揭实收金额占比
from 湖山赋
group by 付款方式名称
having 付款方式名称 != '无';
得到付款方式报表:
最后我们从业态的维度进行分析:
#业态分析表
select distinct 业态,
count(房源名称),
count(房源名称)/(select count(房源名称) from 湖山赋 where 付款方式名称 !='无') as 房源占比,
sum(预测建筑面积),
sum(预测建筑面积)/(select sum(预测建筑面积) from 湖山赋 where 付款方式名称 !='无') as 建筑面积占比,
sum(成交总价已收房款),
sum(成交总价已收房款)/(select sum(成交总价已收房款) from 湖山赋 where 付款方式名称 !='无') as 已收房款占比,
sum(实收房款现金),
sum(实收房款现金)/(select sum(实收房款现金) from 湖山赋 where 付款方式名称 !='无') as 实收房款现金占比,
sum(按揭实收金额),
sum(按揭实收金额)/(select sum(按揭实收金额) from 湖山赋 where 付款方式名称 !='无') as 按揭实收金额占比
from 湖山赋
group by 业态;
得到报表:
本文摘自 :https://blog.51cto.com/u