Maybe SELECT DISTINCTROW?

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Joseph Mann
Sent: Friday, April 12, 2002 12:59 PM
To: [EMAIL PROTECTED]
Subject: Re: SV: [IMail Forum] OT: SQL syntax!



This should do it.  What type of database are you querying?

SELECT DISTINCT IP, WEEK, DATE, COUNT(*) FROM VISITORS
GROUP BY IP, WEEK, DATE ORDER BY DATE ASC;

--
Joe M.



Friday, April 12, 2002, 3:57:29 AM, you wrote:

TT> Thanks, but somehow it doesn't like the "COUNT(DISTINCT Visitors.IP)"...
TT> What should I do?

TT> Thomas :)

TT> -----Oprindelig meddelelse-----
TT> Fra: [EMAIL PROTECTED]
TT> [mailto:[EMAIL PROTECTED]]P� vegne af Norman J.
TT> Nolasco
TT> Sendt: 12. april 2002 00:53
TT> Til: [EMAIL PROTECTED]
TT> Emne: RE: [IMail Forum] OT: SQL syntax!


TT> That will list the distinct combinations of week/ip addresses.  He
TT> needs the count of distinct IPs within the week.  I'm not 100% sure,
TT> but I think it's:

TT> SELECT Visitors.Week, COUNT(DISTINCT Visitors.IP) AS UniqueIPCount
TT> FROM Visitors
TT> GROUP BY Visitors.Week

TT> -Norm

TT> -----Original Message-----
TT> From: [EMAIL PROTECTED]
TT> [mailto:[EMAIL PROTECTED]]On Behalf Of Jerod M.
TT> Bennett
TT> Sent: Thursday, April 11, 2002 5:02 PM
TT> To: [EMAIL PROTECTED]
TT> Subject: RE: [IMail Forum] OT: SQL syntax!


TT> You need to add the DISTINCT parameter to your query.

TT> SELECT DISTINCT Visitors.Week, Visitors.IP
TT> FROM Visitors
TT> GROUP BY Visitors.Week, Visitors.IP;

TT> Jerod M. Bennett
TT> Director of Media Production
TT> Pixelpushers, Inc.


TT> -----Original Message-----
TT> From: [EMAIL PROTECTED]
TT> [mailto:[EMAIL PROTECTED]] On Behalf Of Thomas
TT> Testmann
TT> Sent: Thursday, April 11, 2002 1:18 PM
TT> To: [EMAIL PROTECTED]
TT> Subject: [IMail Forum] OT: SQL syntax!


TT> Hi,

TT> I have a counter on my website, which stores in a table, named
TT> 'Visitors', with the following fields:

TT> [Section],[Page],[Browser],[Country],[Date],[Time],[Year],[Month],[Week]
TT> ,[Da
TT> y],[Referent],[IP]


TT> I would then like to make a query on how many unique IPs there is,
TT> listed by week. However, I don't know how to do it, besides making two
TT> queries, 'IP1' and 'IP2', where it is the last mentioned that shows it.
TT> 'IP2', however makes a query on 'IP1', and I'd like to get a more
TT> "clean" query, that is, directly on the table.

TT> The two queries look like this:

TT> IP1:

TT> SELECT Visitors.Week, Visitors.IP
TT> FROM Visitors
TT> GROUP BY Visitors.Week, Visitors.IP;


TT> IP2:

TT> SELECT [IP1].[Week], Count([IP1].[IP]) AS DifferentIPs
TT> FROM IP1
TT> GROUP BY [IP1].[Week];


TT> I believe I should use some join or union, but can't get it to work...

TT> Really hope that somebody can help here!

TT> Thanks in advance!

TT> Regards,
TT> Thomas Testmann


TT> Please visit http://www.ipswitch.com/support/mailing-lists.html
TT> to be removed from this list.

TT> An Archive of this list is available at:
TT> http://www.mail-archive.com/imail_forum%40list.ipswitch.com/

TT> Please visit the Knowledge Base for answers to frequently asked
TT> questions:  http://www.ipswitch.com/support/IMail/



TT> Please visit http://www.ipswitch.com/support/mailing-lists.html
TT> to be removed from this list.

TT> An Archive of this list is available at:
TT> http://www.mail-archive.com/imail_forum%40list.ipswitch.com/

TT> Please visit the Knowledge Base for answers to frequently asked
TT> questions:  http://www.ipswitch.com/support/IMail/

TT> Please visit http://www.ipswitch.com/support/mailing-lists.html
TT> to be removed from this list.

TT> An Archive of this list is available at:
TT> http://www.mail-archive.com/imail_forum%40list.ipswitch.com/

TT> Please visit the Knowledge Base for answers to frequently asked
TT> questions:  http://www.ipswitch.com/support/IMail/


TT> Please visit http://www.ipswitch.com/support/mailing-lists.html
TT> to be removed from this list.

TT> An Archive of this list is available at:
TT> http://www.mail-archive.com/imail_forum%40list.ipswitch.com/

TT> Please visit the Knowledge Base for answers to frequently asked
TT> questions:  http://www.ipswitch.com/support/IMail/



--
Best regards,
 Joseph                            mailto:[EMAIL PROTECTED]


Please visit http://www.ipswitch.com/support/mailing-lists.html
to be removed from this list.

An Archive of this list is available at:
http://www.mail-archive.com/imail_forum%40list.ipswitch.com/

Please visit the Knowledge Base for answers to frequently asked
questions:  http://www.ipswitch.com/support/IMail/


Please visit http://www.ipswitch.com/support/mailing-lists.html 
to be removed from this list.

An Archive of this list is available at:
http://www.mail-archive.com/imail_forum%40list.ipswitch.com/

Please visit the Knowledge Base for answers to frequently asked
questions:  http://www.ipswitch.com/support/IMail/

Reply via email to