![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a sessions table like the following: SID UserID * * * * * TimeIn * * * * * * * * ** * * * TimeOut 1 * * *10 * * *Aug-10-2011 11:30:45 * * * * * *Aug-10-2011 11:32:13 2 * * *11 * * *Aug-10-2011 11:30:55 * * * * * *Aug-10-2011 11:31:01 3 * * *54 * * *Aug-10-2011 11:31:02 * * * * * *Aug-10-2011 11:33:48 4 * * *21 * * *Aug-10-2011 11:34:11 * * * * * *Aug-10-2011 11:35:19 I need a query to return the count of active users for each records time range, such that: for SID 1, the count would be 3 because there are 3 records whose TimeIn <= SID 1's TimeOut for SID 2, the count would be 2 because there are 2 records whose TimeIn <= SID 2's TimeOut etc. |
#3
| |||
| |||
|
|
On Nov 15, 8:28*am, "hilljm1... (AT) gmail (DOT) com" <hilljm1... (AT) gmail (DOT) com wrote: I have a sessions table like the following: SID UserID * * * * * TimeIn * * * * * * * * * * * * * TimeOut 1 * * *10 * * *Aug-10-2011 11:30:45 * * * * * *Aug-10-2011 11:32:13 2 * * *11 * * *Aug-10-2011 11:30:55 * * * * * *Aug-10-2011 11:31:01 3 * * *54 * * *Aug-10-2011 11:31:02 * * * * * *Aug-10-2011 11:33:48 4 * * *21 * * *Aug-10-2011 11:34:11 * * * * * *Aug-10-2011 11:35:19 I need a query to return the count of active users for each records time range, such that: for SID 1, the count would be 3 because there are 3 records whose TimeIn <= SID 1's TimeOut for SID 2, the count would be 2 because there are 2 records whose TimeIn <= SID 2's TimeOut etc. Some people may answer this, but in general, you will get a better response for this kind of question if you provide table creation and data loading statements. *That way, people can start from the same place you are, and play around until they get what you say you want. This also helps reduce ambiguity with a very small data set. *If you show what you tried, that might help some people think you aren't just asking for people to do your work for you. jg -- @home.com is bogus. Robertson doesn't get it, again:http://www.signonsandiego.com/news/2...vacy-history/- Hide quoted text - - Show quoted text - |
![]() |
| Thread Tools | |
| Display Modes | |
| |