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 |
Daniel Israel
Starting Member
15 Posts |
Posted - 2007-07-30 : 19:47:43
|
Hello,I'm trying to figure out this query, but I'm having trouble (not sure it's possible in one query).I have a table that tracks number of logins like so:LoginName, IPAddress, Count, DateEach time someone logs in, it will check if they've logged in on that date with that login and IP. If they have, it increments the count. If not, it will create a new record and set Count to 1.What I'd like is to have a Query that returns a list of LoginName with a count of unique IPAddress with each LoginName (and, ideally, the total number of logins on that LoginName).Any help on this would be appreciated.-D. Israel |
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-07-30 : 21:46:37
|
try something likeSELECT LoginName, IPAddress, COUNT(*) As NumIP , SUM(Count)FROM LoginTableGROUP BY LoginName, IPAddressDinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
|
|
|
|