Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with creating a table view/query?

Status
Not open for further replies.

pat333

Programmer
Feb 14, 2003
2
GB
Hi,

I'm creating a database that logs the events of users on a website. Basically, as it stands, the DB consists of a single table which has three columns describing a single event which are eventID, userID and date.

What I want to do I create a derived table from that info detailing user session information within SQL (I expect within a View). This would be such that every event falls into a particular session of a particular user. A session is defined as it would normally be (i.e. a user session ends after 20mins of inactivity from that user).

So what the resulting table should consist of is the columns UserID, SessionNumber, Date and EventID. A chain of events belongs within a particular session for as long as the difference in the dates between events is never more than some time (such as 20mins). Any event after that belongs to a subsequent session number for that user.

Can anyone tell me whether it would be possible to create such a View? I have no idea how I would do this in MSSQL alone, without the use of an external script to generate the table each and every time (a lengthy procedure)..

Any ideas?

Thanks,
Pat.
 
It would be more convinient if the table were loaded with sessions in the first place. Doing this recalculation is not that easy using general database syntax/procedures.

If the web application could log every new session this could be loaded and the problem would not arise.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top