SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    The Jellophonic Autobrain CHeeSeBLiND's Avatar
    Join Date
    Jul 2001
    Location
    Bolton, England
    Posts
    584
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    selecting distinct IP

    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

    Code:
    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
    Which gives me the list of sites in the order I want with their hits etc. So far so good.

    but...

    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?

    cheers.
    hmm...

  2. #2
    SitePoint Guru quenting's Avatar
    Join Date
    Dec 2002
    Location
    Switzerland
    Posts
    735
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Count(distinct(ip)) ?
    The largest message boards on the web !
    unblog.fr, hosting 700000 french blogs

  3. #3
    The Jellophonic Autobrain CHeeSeBLiND's Avatar
    Join Date
    Jul 2001
    Location
    Bolton, England
    Posts
    584
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    haha i can't believe i didnt try that, after all the 316 combinations i tried.

    Cheers
    hmm...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •