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 |
|
kevin.woodhouse
Starting Member
1 Post |
Posted - 2009-03-24 : 12:19:56
|
| OK, here goes.I have a cisco Access Control Server (ACS) and send failed authentications successfully to a SQL 2005 database. The table is called failedattempts. I want to be able to select the username and the total number of times that user has failed authentication. I can get to a point where I can pick a unique username and display the number of times that user has failed authentication with the following SQL:SELECT user_Name, COUNT(user_Name)FROM failedattempts GROUP BY user_NameORDER BY count( user_Name) DESCThis results in the following table:User1 12User2 10User3 2No problem so far, however I want to be able to sort on todays date. For example, show me all the failed attempts today, the above list displays all failed attempts since the database was created.If I try to manipulate the results with any date information SQL provides me with a very polite error, there is the problem:Any ideas to sort on date please.Thanks |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-03-24 : 13:35:18
|
| If you want just the failed attempts today..include a WHERE logic in your select statement as below...SELECT user_Name, COUNT(user_Name)FROM failedattempts WHERE date = today's date GROUP BY user_NameORDER BY count( user_Name) DESCIf you need all the attempts grouped by fdate...use the date column as well in the GROUP BY clause.SELECT user_Name, COUNT(user_Name),dateFROM failedattempts GROUP BY user_Name,dateORDER BY count( user_Name) DESC |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-03-25 : 06:18:44
|
| SELECT user_Name, COUNT(user_Name)FROM failedattempts WHERE date_col>=dateadd(day,datediff(day,0,getdate()),0) and date_col<dateadd(day,datediff(day,0,getdate()),1) GROUP BY user_NameORDER BY count( user_Name) DESCMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|