肖sir__笔试sql面试题___归纳
题目:
笔试题:
公司有3张表,销售订单表、经销商信息表、产品信息表
经销商信息表dim_dealer:
产品信息表dim_product:
将以上3张表用sql实现一张事实明细宽表。需要写出sql,以及表最后字段和数据呈现。
用sql写出购买客户数、销售金额和客单价逻辑。
查询每个经销商购买金额排名第二的客户,列出手机号
Select * from dim_dealer, order_detai,dim_ptoduct where dim_dealer.dealer_code=order_detai.dealer_code and order_detail.product_id=dim_dealer.product_id;
Select phone,sum(dael_amt),sum(deal_amt)/count(dael_amt) sc from order_detail group by phone
Select dealer_ name,phone from dim_dealer, order_detai where dim_dealer.dealer_code=order_detai.dealer_code order by deal_amt desc limit 1,1
=========================================================================================================================