www.webdeveloper.com
Results 1 to 4 of 4

Thread: Help with grouping in query

  1. #1
    Join Date
    Mar 2006
    Posts
    5

    Help with grouping in query

    OK... I have a database where I enter stats about who's viewing my site (Country, Browser Type, etc), and one of these fields is the Referring URL. I'm making a query that gives me a count of how many visitors I get from different URLS. I'll use google for this example.

    My query is:
    SELECT COUNT(RefURL) AS ReferCount, RefURL
    FROM SiteStats
    WHERE (RefURL <> '')
    GROUP BY RefURL

    This works great, except for one thing... it sees http://google.com and http://www.google.com as different sites... is there anyways I can parse the RefURL strings and just compare them on the domain?

    Thanks in advance
    Last edited by jrkeyboard; 03-31-2006 at 10:00 AM.

  2. #2
    Join Date
    Aug 2005
    Location
    The Garden State
    Posts
    5,634
    You should be handling that on your insert, either at the application or as part of a trigger, not on your output.

    otherwise, create a view to do it.
    Acceptable Use | SQL Forum FAQ | celery is tasteless | twitter

    celery is tasteless - currently needing some UI time

  3. #3
    Join Date
    Mar 2006
    Posts
    5
    It is being taken care of on the insert now... but since I didn't think it through before starting the data collection, it doesn't help for all the past data...

    Just going on the data from here on out wouldn't be the worst thing in the world, but I just thought I'd see if there was any way the old data wouldn't have to be wasted

    And I'm not familiar with views... I'll have to check on that

    Thanks

  4. #4
    Join Date
    Mar 2006
    Posts
    5
    I've got this taken care of... I wrote up a script that went through and formatted all the existing RefURL's so that they only contain "google.com" now...

    Thanks

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles