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 |
|
Mondeo
Constraint Violating Yak Guru
287 Posts |
Posted - 2007-09-17 : 11:41:35
|
| Got a large table containing the following fieldsUsernameIPAddressI want to return all usernames who have > 1 different/distinct IP addresses.Thanks |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2007-09-17 : 11:46:56
|
| select username,count(distinct IPAdress)from yourtablegroup byusernamehaving count(*) >1 |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-09-17 : 11:50:45
|
| [code]Select UserNamefrom Table1Group by UserNameHaving Count(Distinct IPAddress) > 1[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
Mondeo
Constraint Violating Yak Guru
287 Posts |
Posted - 2007-09-17 : 11:51:54
|
| Thanks,The query works but it includes entries with 1 count.I tried thisSELECT Username, COUNT(DISTINCT IPAddress) AS Expr1FROM tblAppActionsWHERE (Expr1 > 1)GROUP BY UsernameBut it says unknown column Expr1 |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-09-17 : 11:52:37
|
Less CPU, same time.Select UserNamefrom Table1Group by UserNameHaving min(IPAddress) < max(ipadress) E 12°55'05.25"N 56°04'39.16" |
 |
|
|
|
|
|