我有一个如下所示的查询:
select uid,leadcount,salescount,leadcount/salescount as diff from
(
SELECT x.uid, COUNT(*) leadcount, COUNT(DISTINCT x.fid)
FROM total_leads AS x
WHERE x.uid BETWEEN 1 AND 5
GROUP BY x.uid
) t1 left join
(
SELECT ud.UserId, COUNT(*) salescount, COUNT(DISTINCT ud.SalesID)
FROM total_sales AS ud
WHERE ud.UserId BETWEEN 1 AND 5
GROUP BY ud.UserID
) t2 on t1.uid=t2.UserId
结果是:
我试图仅显示diff
大于的结果2.5
(因此在这种情况下,输出中应该只有uid
5 个可见)。
我尝试使用WHERE diff >= 2.5
但我得到了"You have an error in your SQL syntax"。