我正在尝试计算购买前一天发生的产品页面浏览量。我用过这个查询
SELECT
p.customer_id AS cid,
p.product_id AS product,
p.revenue,
p.order_id,
p.datetime,
pv.customer_id,
pv.product_id,
pv.datetime AS date,
od.name2,
COUNT(pv.product_id)
FROM
customer_profiles.purchase p
LEFT JOIN
customer_profiles.product_view pv ON pv.customer_id = p.customer_id
LEFT JOIN
opencart.product_description od ON od.product_id = p.product_id
AND od.language_id = 2
WHERE
pv.datetime BETWEEN DATE_SUB(DATE(p.datetime),
INTERVAL 1 DAY) AND DATE(p.datetime)
AND pv.product_id = p.product_id
GROUP BY pv.product_id
但是计数不正常它会给出一个随机数。我已经使用过count(DISTINCT pv.product_id),遗憾的是它对我来说也不起作用?