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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to find the no of logins every 10 mins

Author  Topic 

anandmuthiah
Starting Member

2 Posts

Posted - 2011-02-16 : 18:41:48
Hi,

I have a table called UserLogin having Date, time and loginName in SQL server. I need to get the no of logins for every 10 min. Say for example time 0:00 - 15,
0:10- 5,
0:20-32 like that.

How can I achive this.

Thanks,
Anand

Anand

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-02-16 : 19:08:45
You can query master..sysprocesses and look for spids greater than 50. Run a job every 15 minutes and have your date/time column use GETDATE as the default.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

anandmuthiah
Starting Member

2 Posts

Posted - 2011-02-16 : 20:28:02
The data stored in the Table is not current data. It is up to previous day data. Like that I have data for a month. I need the no of Login's for every 10 minutes for the hole month day by day. Say for every day I must have 144 entries(6 entries per hour * 24).

Thanks

Anand
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-02-16 : 20:32:11
sysprocesses has current data, so I am not understanding your last post.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2011-02-17 : 08:58:05
Try following the "How to ask" link in my signature, and provide the information it requests. Then we can come up with a much better answer for you.
OR Peter will see this, read your mind, and give you the correct answer.

http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx
How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-02-17 : 09:52:05
UserLogin having Date, time and loginName in SQL server
SELECT DATEADD(MINUTE, DATEDIFF(MINUTE, 0, [Time]), 0), COUNT(*)
FROM dbo.UserLogin
WHERE [Date] = '20110217'
GROUP BY DATEADD(MINUTE, DATEDIFF(MINUTE, 0, [Time]), 0)
ORDER BY DATEADD(MINUTE, DATEDIFF(MINUTE, 0, [Time]), 0)



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -