Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
jameswoodmancy
Starting Member
13 Posts |
Posted - 2009-07-08 : 11:48:50
|
| Hi, I want to perform a sql statement which counts the number of times a page has been visisted..like thisSELECT Title FROM Page ,(SELECT COUNT(*) FROM UserJourney WHERE Page.ID = UserJourney.PageID) AS ViewCountFROM [Pages]ORDER BY [OrderBy]however, i have a column called sessionID in the table UserJourney and I want to group by this column so if a user goes to the page twice in one session then it will only be counted once. I'm having difficulty working out the SQL statement for this. any ideas where to start?thanks for your help |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-07-08 : 11:58:49
|
| [code]SELECT p.Title, uj.ViewCount FROM [Pages] pCROSS APPLY (SELECT COUNT(DISTINCT sessionID) AS ViewCount FROM UserJourney WHERE PageID=p.ID ) ujORDER BY [OrderBy][/code] |
 |
|
|
jameswoodmancy
Starting Member
13 Posts |
Posted - 2009-07-13 : 12:05:46
|
| thanks!! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-07-13 : 13:46:41
|
| welcome |
 |
|
|
|
|
|