我正在使用以下查询返回一些统计信息,但我遇到了一个小问题。查询工作正常,但有时报价不正确。在错误的情况下,它会显示报价与 item_views 的编号相同。我真的不知道为什么。想知道是否有人可以帮助我。
SELECT i.id,
i.title,
i.slug,
i.seller_id as seller_id,
i.date_added as date_added,
a.slug as area_slug,
COUNT(o.id) as offer,
COUNT(v.item_id) as total_item_views,
(COUNT(v.item_id) / COUNT(o.id)) * 100 conversion,
(UNIX_TIMESTAMP(v.time_ended) - UNIX_TIMESTAMP(v.time_started)) / 60 difference_minutes,
SUM(CASE WHEN v.time_ended - v.time_started < 10 THEN 1 ELSE 0 END) bounce,
COUNT(DISTINCT v.session_id) unique_views
FROM item as i
LEFT JOIN offer as o
ON i.id = o.item_id
LEFT JOIN viewed_item as v
ON i.id = v.item_id
INNER JOIN area as a
ON a.id = i.area_id
WHERE i.id = 1
谢谢你的时间
强尼