MySQL如何计算动销率_20161025
时间:2021-07-01 10:21:17
帮助过:22人阅读
c.
*,d.库存商品数,c.销售商品数
/d.库存商品数
AS 动销率
FROM (#各城市各月销售商品数
SELECT b.城市,b.年月,
COUNT(b.商品ID)
AS 销售商品数
FROM (
SELECT a.city
AS 城市,a.`productID`
AS 商品ID,DATE_FORMAT(a.`order_date`,"
%Y
%m")
AS 年月
FROM `test_a03order`
AS a#订单表
GROUP BY a.city ,a.`productID` ,DATE_FORMAT(a.`order_date`,"
%Y
%m")
) AS b
GROUP BY b.城市,b.年月
) AS c
LEFT JOIN (#各城市各月库存商品数
SELECT b.城市,b.年月,
COUNT(b.商品ID)
AS 销售商品数
FROM (
SELECT a.city
AS 城市,a.`productID`
AS 商品ID,DATE_FORMAT(a.`date`,"
%Y
%m")
AS 年月
FROM `test_a05order`
AS a#库存表
GROUP BY a.city ,a.`productID` ,DATE_FORMAT(a.`date`,"
%Y
%m")
) AS b
GROUP BY b.城市,b.年月
) AS d
ON c.城市
=d.城市
AND c.年月
=d.年月
MySQL如何计算动销率_20161025
标签:rom orm 它的 format and span 品种 date city