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 |
|
Benny57
Starting Member
4 Posts |
Posted - 2012-08-31 : 02:19:23
|
| Hi!I need some help with a query.I have a table called A with 2 fields called B and C.The field B is just a field that contains a number range starting at 1 and just continue to eternity.And field C is a field that contains userid, 1 to 300.The same Userid can occur more then once against different number in field B .I need to know how many userid's that occur more than once in table A and how many specific userid there are in the table.The table contains approximately 25000 rows. |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-08-31 : 07:02:20
|
| [code]--I need to know how many userid's that occur more than once in table ASELECT C FROM A GROUP BY C HAVING COUNT(*) > 1;-- and how many specific userid there are in the table.SELECT COUNT(DISTINCT C) FROM A;[/code] |
 |
|
|
Benny57
Starting Member
4 Posts |
Posted - 2012-08-31 : 09:17:17
|
Ok thank's sunitabeck, works perfect |
 |
|
|
|
|
|