首页 > 代码库 > MySQL_各城市在线产品天订单数据20161130

MySQL_各城市在线产品天订单数据20161130

#sealreport010 `tb010_02d`各城市在线产品天订单数据

#sealreport010 `tb010_02d`各城市在线产品天订单数据
SELECT d.ID,a.城市,a.在线日期,c.商品分类一级,c.商品分类二级,c.商品分类三级,a.产品ID,c.产品名称,b.汇总单品量,订单额
FROM (
    SELECT 城市,DATE(在线日期) AS 在线日期,产品ID
    FROM `a010_dynamic_产品`
    WHERE 在线日期>=2016-08-04 AND 在线日期<CURRENT_DATE
    GROUP BY 城市,DATE(在线日期),产品ID
) AS a
LEFT JOIN (
    SELECT 城市,DATE(订单日期) AS 订单日期,产品ID,SUM(汇总单品量) AS 汇总单品量,SUM(金额) AS 订单额
    FROM `a003_order` 
    WHERE 订单日期>=2016-08-04 AND 订单日期<CURRENT_DATE AND 金额>0 
    GROUP BY 城市,DATE(订单日期),产品ID
) AS b ON a.城市=b.城市 AND a.产品ID=b.产品ID AND a.在线日期=b.订单日期
LEFT JOIN `a002_产品` AS c ON a.产品ID=c.产品ID
LEFT JOIN `a000_city` AS d ON a.城市=d.城市

 

MySQL_各城市在线产品天订单数据20161130