兴安盟建设局网站,深圳建设银行,做网站手机软件,网页设计模板 中文目录1、要完成的任务2、认识数据3、SQL数据加工4、excel形成分析仪1、要完成的任务
目标#xff1a;结合SQL和excel实现餐饮业日销售情况分析仪#xff0c;如下表#xff1a; 认识分析仪#xff1a; 切片器#xff1a;店面 分为四部分#xff1a;KPI 、组合图、饼图、数…
目录1、要完成的任务2、认识数据3、SQL数据加工4、excel形成分析仪1、要完成的任务
目标结合SQL和excel实现餐饮业日销售情况分析仪如下表 认识分析仪 切片器店面 分为四部分KPI 、组合图、饼图、数据透视表 KPI指标
当天销售情况当天桌子使用情况当天每把椅子的使用情况 组合图每小时的销售额与销量变化趋势 饼图不同菜品下的销售额占比情况销量占比情况 数据透视表不同菜品下的销售额情况销量情况
2、认识数据
表结构信息 bill表中缺失金额order表缺失店名信息 —bill表与order表连接一下可以解决 反映不同店的桌子信息 shop表要补充总座位表
3、SQL数据加工 用orderdetail表创建单汇总金额表OrderGroup–计算每单号的总金额 以orderdetail表的billnumber单号字段为汇总依据求出每条billnumber下pay的加总值。 新表字段billnumber单号、pay金额 用Bill表与OrderGroup表创建新单号详细表NewBill–newbill bill每单总金额每单折扣后金额 以billnumber为关键字段关联两表将OrderGroup表中的pay字段合并到Bill表中并使用pay与billdiscount字段计算出折扣金额。 新表字段所有Bill表中的字段、pay金额、rebate折扣金额 计算逻辑Rebate pay * billdiscount 用Shopdetail表创建新店面情况表NewShopDetail–添加每家店的总座位数 在原有shopdetail表字段基础上计算并添加allseats字段 新表字段所有ShopDetail表中的字段、allseats总座位数 计算逻辑allseats twotable * 2 three * 3 fourtable * 6 用OrderDetail表与Bill表创建新点菜明细表NewOrderDetail–给order表增加店名信息 以billnumber为关键字段关联两表并用Bill表中的shopname与OrderDetail表中的所有字段组成新表 新表字段shopname店名、OrderDetail表中的所有字段 用NewBill表与NewShopDetail表创建店汇总信息表ShopTotal 以shopname字段为关键字段关联两表并以shopname字段为汇总条件创建以下字段 新表字段 店名 b.shopname 单数 b.billnumber的计数 人数 b.peoplecount的加总 折扣总金额 b.rebate的加总 店汇总金额 b.pay的加总 单均消费 b.pay的合计值/b.billnumber的计数值 人均消费 b.pay的合计值/b.peoplecount的合计值 总台数 s.alltable 总座位数 s.allseats 翻台率 b.billnumber的计数值/s.alltable 总单数/总桌数 上座率 b.peoplecount的合计值/s.allseats 折扣率 b.rebate的合计值/b.pay的合计值
导入bill表
create database CateringCase;use CateringCase;-- Bill table
create table Bill(billdate date not null,billnumber varchar(20) not null default -,shopname varchar(20) not null default -, billdiscount float not null default 0,paytime time not null,tablenumber int not null default 0,peoplecount int not null default 0
);#导入数据
load data local infile D:/liwork/data/-bill.csv into table Billfields terminated by ,;select * from Bill;导入OrderDetail表
-- OrderDetail table
create table OrderDetail(billnumber varchar(20) not null default -,detail varchar(20) not null default -,pay int not null default 0
);#导入数据
load data local infile D:/liwork/data/-order.csv into table OrderDetailfields terminated by ,;select * from OrderDetail;导入ShopDetail表
-- ShopDetail table
create table ShopDetail(ShopName varchar(20) not null default -,twotable int not null default 0,threetable int not null default 0,fourtable int not null default 0,alltable int not null default 0
);#导入数据
load data local infile D:/liwork/data/-shop.csv into table ShopDetailfields terminated by ,;select * from ShopDetail;数据加工
-- 数据加工
-- 创建单汇总金额表
Create table OrderGroup(select billnumber, sum(pay) as pay from OrderDetailgroup by billnumber
);select * from OrderGroup;-- 创建新单号详细表
Create table NewBill(
select b.*,o.pay,b.billdiscount * o.pay as rebate from bill as b left join ordergroup as o
on b.billnumber o.billnumber);select * from NewBill;
NewBill表 -- 创建新店面情况表
create table NewShopDetail(
select *, (twotable * 2 threetable * 3 fourtable * 6) as allseats
from shopdetail as s);select * from NewShopDetail;
NewShopDetail表
-- 创建新点菜明细表
create table neworderdetail(
select b.shopname,o.* from orderdetail as o left join bill as b
on o.billnumber b.billnumber
);select * from neworderdetail;neworderdetail表 -- 创建店汇总信息表
create table ShopTotal(
select b.shopname as 店名, count(b.billnumber) as 单数,
sum(b.peoplecount) as 人数,sum(b.rebate) as 折扣总金额,sum(b.pay) as 店汇总金额,
sum(b.pay)/count(b.billnumber) as 单均消费,
sum(b.pay)/sum(b.peoplecount) as 人均消费,
s.alltable as 总台数,
s.allseats as 总座位数,
count(b.billnumber)/s.alltable as 翻台率,
sum(b.peoplecount)/s.allseats as 上座率,
sum(b.rebate)/sum(b.pay) as 折扣率
from newbill as b left join newshopdetail as s
on b.shopname s.shopname
group by b.shopname);select * from shoptotal;shoptotal表
4、excel形成分析仪
从excel中连接MySQL导入数据后做数据透视图不断调整