Forum Moderators: open
SELECT ((COUNT(bookings.quoteid) / COUNT(referers.keywords)) * 100) AS conversion, COUNT(referers.keywords) AS keyword_count, referers.keywords AS keywords FROM quotes INNER JOIN referers ON quotes.quoteid = referers.quoteid LEFT JOIN bookings ON quotes.quoteid = bookings.quoteid WHERE 1 GROUP BY referers.keywords ORDER BY counted DESC Now what I tried to do was to add in some extra WHERE clause, that would only return results where the "keyword_count" was higher than 5.
However, "WHERE keyword_count > 5" is false, and so is "WHERE COUNT(referers.keywords) > 5"...
Any guru's around?
.. and try to add "HAVING keyword_count > 5" after the "GROUP BY.. " statement
And yes, that did the trick:
SELECT ((COUNT(bookings.quoteid) / COUNT(referers.keywords)) * 100) AS conversion, COUNT(referers.keywords) AS keyword_count, referers.keywords AS keywords FROM quotes INNER JOIN referers ON quotes.quoteid = referers.quoteid LEFT JOIN bookings ON quotes.quoteid = bookings.quoteid WHERE 1 GROUP BY referers.keywords HAVING keyword_count > 5 ORDER BY counted DESC Hope this helps anyone else besides me :)