I'm wokring on a traffic script and want to show the top x sites and the traffic they're bringing in. The query i have so far is as follows
Which gives me the list of sites in the order I want with their hits etc. So far so good.
SELECT t.trade_id, tr.trade_url, tr.trade_name, COUNT(*) AS hits
FROM traffic t
LEFT JOIN trades tr
ON t.trade_id = tr.trade_id
WHERE t.trade_id <> 0
AND t.traffic_in = 1
GROUP BY t.trade_id
HAVING hits > 5
ORDER BY hits DESC
I just want to count the unique hits. The table has a field for the IP of the user [t.traffic_ip], so my question is:
How do i modify the above query so that it just select the unqiue IPs and not all of them?