表部分

 np_third_store_info  公司信息 

SELECT info.store_id AS thirdId
,info.store_name AS storeName
,o.sumPrice
,b.orderCount
,c.followCount
,e.sumPro AS sumPro
,(b.orderCount/d.allCount)*100 AS takeRates
FROM np_third_store_info info
LEFT JOIN (SELECT SUM(order_price) AS sumPrice
,business_id FROM np_order
WHERE order_status='3' AND LEFT(pay_time,10) GROUP BY business_id ) AS o
ON o.business_id = info.store_id

LEFT JOIN (SELECT COUNT(1) AS orderCount
,business_id FROM np_order
WHERE order_status='3' AND LEFT(pay_time,10)
GROUP BY business_id ) AS b
ON b.business_id = info.store_id

-- (某段时间内)统计未删除标记的商品关注量
LEFT JOIN (
SELECT COUNT(1) AS followCount -- 关注量
,ifo.third_id
FROM np_customer_follow f
,np_goods_info ifo
WHERE f.goods_id = ifo.goods_info_id
AND f.del_flag = '0'
AND LEFT(f.create_time,10) BETWEEN '2018-12-01' AND '2018-12-31'--在日期之内的商品的关注数量(并且是未删除标记的)
GROUP BY ifo.third_id ) c
ON c.third_id = info.store_id
-- 商家数量
LEFT JOIN (
SELECT COUNT(1) AS allCount
,business_id -- 商家ID
FROM np_order
WHERE 1=1 AND LEFT(pay_time,10) BETWEEN '2018-12-01' AND '2018-12-31'
GROUP BY business_id
) d
ON d.business_id = info.store_id

LEFT JOIN(
SELECT SUM(goods_info_num) AS sumPro
,ord.business_id -- 商家ID
FROM np_order_goods goods
, np_order ORD
WHERE goods.order_id = ord.order_id
AND ord.order_status ='3'-- 已经收货的
AND LEFT(pay_time,10) BETWEEN '2018-12-01' AND '2018-12-31'-- 此处设置时间限制
GROUP BY ord.business_id
)e
ON e.business_id=info.store_id
WHERE info.store_status = 1

----------------------------------------------------------
(SELECT
info.store_id AS thirdId,
info.store_name AS storeName,
o.sumPrice AS sumPrice,
b.orderCount AS orderCount,
e.sumPro AS sumPro,
(b.orderCount / d.allCount) * 100 AS takeRates,
info.create_time AS createTime
FROM np_third_store_info info
LEFT JOIN (SELECT
SUM(order_price) AS sumPrice,
business_id
FROM np_order
WHERE 1=1

iml是 intellij idea的工程配置文件,里面是当前projec的一些配置信息

猜你喜欢

转载自www.cnblogs.com/danJuly/p/10208698.html