2019网易校招题

好评率是会员对平台评价的重要指标。现在需要统计2018年1月1日到2018年1月31日,用户'小明'提交的母婴类目"花王"品牌的好评率(好评率=“好评”评价量/总评价量):

用户评价详情表:a

字段:id(评价id,主键),create_time(评价创建时间,格式'2017-01-01'), user_name(用户名称),goods_id(商品id,外键) ,

sub_time(评价提交时间,格式'2017-01-01 23:10:32'),sat_name(好评率类型,包含:“好评”、“中评”、“差评”)

商品详情表:b

字段:good_id(商品id,主键),bu_name(商品类目), brand_name(品牌名称)

 

select count(if(A.sat_name = '好评',A.id,null))/count(A.id) as '好评率'

from

((select id,goods_id,sat_name from a

where cast(sub_time as timestamp) between cast('2018-01-01 00:00:00' as timestamp) and cast('2018-01-31 23:59:59' as timestamp) and user_name = '小明') as A

join

(select goods_id,bu_name,brand_name from b

where bu_name='母婴'

and brand_name = "花王") as B

on A.goods_id = B.goods_id)

考拉运营"小明"负责多个品牌的销售业绩,请完成:

(1)请统计小明负责的各个品牌,在2017年销售最高的3天,及对应的销售额。

销售表 a:

字段:logday(日期,主键组),SKU_ID(商品SKU,主键组),sale_amt(销售额)

商品基础信息表 b:

字段:SKU_ID(商品SKU,主键),bu_name(商品类目),brand_name(品牌名称),user_name(运营负责人名称)

(2)请统计小明负责的各个品牌,在2017年连续3天增长超过50%的日期,及对应的销售额。

#Using MYSQL

create view table_joined as (

select * from a,b

where a.SKU_id=b.SKU_id

and user_name='小明'

and year(logday)=2017)

 

select v1.logday,v1.amt from table_joined v1

where 3<(select count(*) from table_joined v2

where v1.brand_name=v2.brand_name

and v1.sale_amt<v2.sale_amt)

order by logday,sale_amt

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值