simple SQL query problem...
From: Chris Dangerfield (chris_at_dangerfieldbrothers.co.uk)
Date: 05/25/04
- Next message: Jim Bancroft: "A way to select random records?"
- Previous message: Rich: "Re: how to update a count field with incremental values?"
- Next in thread: Adam Machanic: "Re: simple SQL query problem..."
- Reply: Adam Machanic: "Re: simple SQL query problem..."
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 25 May 2004 20:57:07 +0100
Hi there,
I could do with a little help on a sql query.
I have a table with 4 cols
resolution, browser, datetime, ipaddress
I am trying to establish how many unique visitors in a receiving and what
browser and resolution they are using.
CREATE VIEW dbo.view_www_visitor_stats
AS
SELECT TOP 100 PERCENT resolution, COUNT(resolution) AS [count]
FROM dbo.tbl_www_visitor_stats
GROUP BY resolution
ORDER BY COUNT(resolution) DESC
The query above produces the results I require, only when I need to add in
the requirement to ensure the query is being run on a unique ip address.
Sometimes my users are notching up more than one row in the database...
ie...
1024*768 Internet Explorer 25/05/2004 19:11:31
194.165.174.153
1024*768 Internet Explorer 25/05/2004 19:12:31
194.80.193.160
800*600 Internet Explorer 25/05/2004 19:12:33 195.92.67.75
800*600 Internet Explorer 25/05/2004 19:14:10 195.92.67.75
1024*768 Internet Explorer 25/05/2004 19:14:22 82.32.114.126
800*600 Internet Explorer 25/05/2004 19:14:26 195.92.67.75
Note the duplication of rows 3&4, from the same user.
My query gives me...
1024*768 3
800*600 3
What it should do is discount one of the 800*600, as it came from the same
ip address.
So I need this query to be run against distinct ip addresses, however, I
can't seem to get it to work with the distinct keyword or group by.
Can someone help ?
Best Regards
-- Chris Dangerfield
- Next message: Jim Bancroft: "A way to select random records?"
- Previous message: Rich: "Re: how to update a count field with incremental values?"
- Next in thread: Adam Machanic: "Re: simple SQL query problem..."
- Reply: Adam Machanic: "Re: simple SQL query problem..."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|