| Author |
Topic |
|
dimoss
Yak Posting Veteran
52 Posts |
Posted - 2007-07-17 : 11:13:50
|
| Hi,I use the following query in my stats page to find the unique visitors and the pages they visited per day in a given month.SELECT CONVERT(CHAR(10),LogDate,103) As Date_,Count(DISTINCT LogRemote_Addr) As Visitors,Count(Lid) As PagesFROM LogWHERE LogMonth=7Group by CONVERT(CHAR(10),LogDate,103)ORDER BY CONVERT(CHAR(10),LogDate,103)I would like to have the totals (Sum) of the "Visitors" and "Pages" also for the given month.I think I have to use a subquery to accomplish that but I can't figure it out. I would appreciate your help.Thanks,Deniwww.tabletennis.gr |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-07-17 : 11:37:08
|
| [code]SELECT DATEADD(DAY, DATEDIFF(DAY, 0, LogDate), 0) As Date_, Count(DISTINCT LogRemote_Addr) As UniqueVisitors, Count(LogRemote_Addr) As TotalVisitors, Count(DISTINCT Lid) As UniquePages, Count(Lid) As TotalPagesFROM LogWHERE LogDate >= '20070101' AND LogDate < '20070801'Group by DATEADD(DAY, DATEDIFF(DAY, 0, LogDate), 0)ORDER BY DATEADD(DAY, DATEDIFF(DAY, 0, LogDate), 0)[/code]Peter LarssonHelsingborg, Sweden |
 |
|
|
dimoss
Yak Posting Veteran
52 Posts |
Posted - 2007-07-17 : 11:50:45
|
| It doesn't work. I don't take the correct results.www.tabletennis.gr |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
dimoss
Yak Posting Veteran
52 Posts |
Posted - 2007-07-17 : 12:10:39
|
| Ok. I have the following fileds.LogDate = date of visitLogRemoteAddr = ip of the visitorLid = a common id (autonumber)The exampleLid LogDate LogRemoteAdd1 15/7/2007 85.82.141.12 15/7/2007 85.82.141.13 15/7/2007 85.21.140.584 16/7/2007 85.21.140.585 16/7/2007 193.54.147.16 17/7/2007 193.57.100.1This set would produceDate Visitors Pages15/7/2007 2 316/7/2007 2 217/7/2007 1 1I would like to take the Sum of Visitors and Pages which is to 5 and 6 correlatively.I think it's more clear now.Thankswww.tabletennis.gr |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-07-17 : 12:21:44
|
| Where would you like to take them? Picnic?Peter LarssonHelsingborg, Sweden |
 |
|
|
dimoss
Yak Posting Veteran
52 Posts |
Posted - 2007-07-17 : 12:47:46
|
| Not PicNic.The example was clear. Can you help?www.tabletennis.gr |
 |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-07-17 : 12:52:27
|
| [code]SET DATEFORMAT dmygoDeclare @logvisits table (Lid int, LogDate datetime, LogRemoteAdd varchar(50))insert into @logvisitsselect 1, '15/7/2007', '85.82.141.1' union allselect 2, '15/7/2007', '85.82.141.1' union allselect 3, '15/7/2007', '85.21.140.58' union allselect 4, '16/7/2007', '85.21.140.58' union allselect 5, '16/7/2007', '193.54.147.1' union allselect 6, '17/7/2007', '193.57.100.1'select * from @logvisits Select LPages.logDate, Visitors=Lvisit.vcount, Pages=Lpages.Pages From ( Select LogDate, count(*) as Pages From @logvisits Group by LogDate ) LPagesJoin ( Select l3.LogDate , count(*) as Vcount from ( Select LogDate, LogRemoteAdd, count(*) as Visitors from @logvisits Group by LogDate, LogRemoteAdd ) l3 group by l3.logdate ) LVisit on LPages.LogDate = Lvisit.logdate [/code]Dinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
dimoss
Yak Posting Veteran
52 Posts |
Posted - 2007-07-18 : 05:47:46
|
| Maybe the answer is a creation of a temporary table with the fields "Visitors", "Pages" and then call it from a simple Select statement with SUM.Any help??www.tabletennis.gr |
 |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-07-18 : 12:16:54
|
| Did you try the query I posted? Was it not helpful?Dinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
|