473,480 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Finding total and Concurrent number of users logged in

4 New Member
Hi,

I am creating a report for which i need to query a table for total number of users and Concurrent users logged in.

The table will contain Username(nvarcar,not null),SessionStart time(datetime, not null), SessionEnd time (datetime,null), SessionID(int,not null) and ConnectGUID(uniqueidentifier, not null) etc

can any one help me in finding total and number of concurrent logins per day.

Sample Data


Username --- Starttime --- Endtime --- SessionID

FW8126 --- 26/06/2007 00:36:34 --- 26/06/2007 01:43:42 --- 301821503
P1049 --- 26/06/2007 00:43:43 --- 26/06/2007 02:33:32 --- 1056070312
P1088 --- 26/06/2007 00:47:41 --- 26/06/2007 09:51:29 --- 312634269
R0744 --- 26/06/2007 00:47:44 --- 26/06/2007 09:46:13 --- 1068848038
P1055 --- 26/06/2007 01:03:40 --- 26/06/2007 09:54:44 --- 682893510
B0068 --- 26/06/2007 01:08:28 --- 26/06/2007 09:44:26 --- 1905880435
L0195 --- 26/06/2007 01:10:17 --- 26/06/2007 11:01:45 --- 1409172428
L0224 --- 26/06/2007 01:15:49 --- 26/06/2007 12:21:39 --- 168963861

Thanks in advance.
krvrk
Jun 28 '07 #1
6 15390
krvrk
4 New Member
any ideas or code please!!!!!!
Jun 29 '07 #2
Motoma
3,237 Recognized Expert Specialist
Could you elaborate on what you mean by concurrent logins per day?

The total should just be:
Expand|Select|Wrap|Line Numbers
  1. SELECT
  2.   COUNT(*)
  3. FROM
  4.   Table
  5. WHERE
  6.   SessionStart BETWEEN <date1> AND <date2>
  7.     OR
  8.   SessionEnd BETWEEN <date1> AND <date2>
  9.  
Hi,

I am creating a report for which i need to query a table for total number of users and Concurrent users logged in.

The table will contain Username(nvarcar,not null),SessionStart time(datetime, not null), SessionEnd time (datetime,null), SessionID(int,not null) and ConnectGUID(uniqueidentifier, not null) etc

can any one help me in finding total and number of concurrent logins per day.

Sample Data


Username --- Starttime --- Endtime --- SessionID

FW8126 --- 26/06/2007 00:36:34 --- 26/06/2007 01:43:42 --- 301821503
P1049 --- 26/06/2007 00:43:43 --- 26/06/2007 02:33:32 --- 1056070312
P1088 --- 26/06/2007 00:47:41 --- 26/06/2007 09:51:29 --- 312634269
R0744 --- 26/06/2007 00:47:44 --- 26/06/2007 09:46:13 --- 1068848038
P1055 --- 26/06/2007 01:03:40 --- 26/06/2007 09:54:44 --- 682893510
B0068 --- 26/06/2007 01:08:28 --- 26/06/2007 09:44:26 --- 1905880435
L0195 --- 26/06/2007 01:10:17 --- 26/06/2007 11:01:45 --- 1409172428
L0224 --- 26/06/2007 01:15:49 --- 26/06/2007 12:21:39 --- 168963861

Thanks in advance.
krvrk
Jun 29 '07 #3
krvrk
4 New Member
Thanks for your reply.

Could you elaborate on what you mean by concurrent logins per day?

Concurrent logins per day means, total no of Simultaneous sessions per day.

Thanks in advance.
krvrk
Jul 2 '07 #4
Motoma
3,237 Recognized Expert Specialist
Concurrent logins per day means, total no of Simultaneous sessions per day.
You have still been ambiguous in your explanation...
Do you mean the max number of people logged on at one time?
Or just the number of people who logged in?

Let me give you an example of why I think you need to refine your thinking of what you are looking for:

Expand|Select|Wrap|Line Numbers
  1. -------                             Time
  2. User 1  ------------------------------------------------------------
  3. User 2  --------------------                             ----------
  4. User 3  -----------                             --------------------
  5. User 4                 ------------------           
  6.  
In the above (poorly designed) graph, you have 4 users logging in over the course of the day. What would be the number you are looking for for "total simultaneous users"?
Jul 2 '07 #5
krvrk
4 New Member
Hi Motoma,

Sorry for confusing you.

Actually i have been told to calculate concurrent users day.
There will be around 200 logins per day, in that i need to calculate concurrent logins per day.

I don't have any idea that which is best way to calculate concurrent logins per day (i.e claculating hourly concurrent logins per day and then averaging or calculating Max no of concurrent logins in any hour.)

So, Please suggest me best way and code.

Expand|Select|Wrap|Line Numbers
  1. -------        
  2. ---Time       8       9      10   11    12    13     14
  3. User 1  ------------------------------------------------------------
  4. User 2  --------------------                      ------------------
  5. User 3  -----------                               ------------------
  6. User 4                   ------------------        
  7. User 5            --------------------------------- 
  8. User 6            --------
  9. User 7            ------
  10. User 8                                          ---------------------
  11. User 9                                         ----------------------
  12. User 10                 --------------------------------------------             
  13.  
  14.  
In the above example, At 8 No of concurrent users are 3, at 9 concurrent users are 5 and at 14 no of concurrent users are 6.

from this i want Average / Max concurrent(simultaneous) users loged for a single day.

I hope this (modified your example) will give clear idea.

Thanks for your replies.

krvrk
Jul 2 '07 #6
mihir2508
1 New Member
CREATE TABLE Sessions
(key_col INT NOT NULL IDENTITY PRIMARY KEY,
Hour_Min VARCHAR(10) NOT NULL,
usr VARCHAR(50) NOT NULL,
starttime DATETIME NOT NULL,
endtime DATETIME NOT NULL,
CHECK(endtime > starttime))

the Hour_Min is important, if you want max concurrent by hour then insert only the Hour part of the Session starttime in Hour_Min column. For eg, 10, 11, 12, 13, 15 (hours). You will get Max concurrent user for that hour.

if you want max concurrent by minute for eg. for 11:40 , 11:42 and so on, put the Hour:Minute part of the session starttime in Hour_Min column


SELECT Hour_Min, MAX(concurrent) AS mx
FROM (SELECT S1.Hour_Min, S1.key_col, COUNT(*) AS concurrent
FROM Sessions AS S1
JOIN Sessions AS S2
ON S1.Hour_Min = S2.Hour_Min
AND S1.starttime >= S2.starttime
AND S1.starttime < S2.endtime
GROUP BY S1.Hour_Min, S1.key_col) AS C
GROUP BY Hour_Mi
Aug 28 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
17604
by: Tim Morrison | last post by:
SQL Server 2000 - MSDE 2000 Is there a way to get the number of current users logged into a SQL 2000 Server (also MSDE)? Cant be distinct users as most users are logged into the database using the...
36
3544
by: Wei Su | last post by:
Hi, I have a text file abc.txt and it looks like: 12 34 56 23 45 56 33 56 78 ... .. .. ... .. .. I want to get how many rows totally in the text file, how to do this? Thanks.
2
1780
by: Lenn | last post by:
Hello, This requirement might seem strange to someone out there, but here it's We need to make sure only certain number of users can be logged in the site at the same time. Is there any way to...
1
2881
by: Augusto Ruiz García | last post by:
Hello all, Is there any way of finding out the number of pages a PrintDocument has using current Printer settings? If so, how can it be done? TIA.
19
4406
by: gk245 | last post by:
Trying to write a program that will figure out if a number is perfect or not. Here is my logic: 1) Read in the number 2) Split it up (number - 1) 3) Put all the split up numbers into an...
5
3990
by: jjw | last post by:
I have a website that requires users to login. We track them by using sessions. We record the time and date that they login, their session id, the last page they visited, etc in a database. As...
8
3725
by: Mike P | last post by:
What would be the best way of counting the number of users who are currently logged on to a website? I am making the users login against a database of valid users. Would the best way be to add a...
2
4869
by: babe20042004 | last post by:
How would I go about finding every nth number in an array set? For example if i had a set containing the numbers 1-100 int each cell, how would I go about finding every 3rd number in the set.
5
6713
by: mblank | last post by:
Hi~,i'm trying to get a ppt's total slide number,with the office com,but i don't know which method will help, my code can open a ppt only~ Object Nothing = Missing.Value; ...
0
7041
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
6737
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6921
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4776
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
2995
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2984
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
179
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.