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 |
|
JLGoldenEagle
Starting Member
1 Post |
Posted - 2009-07-08 : 14:45:35
|
| I am new to SQL and find it very tricky. In the following, the GID is unique but the CID is not. How do you find how many GID's are on each and every CID?Example Table:CID GID1 1002 2001 1321 1122 2103 3003 331Every where I go, There I am!! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-07-08 : 14:47:03
|
| [code]SELECT CID,COUNT(GID) AS GIDCountFROM YourTableGROUP BY CID[/code] |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-07-09 : 10:14:31
|
quote: Originally posted by X002548
quote: Originally posted by JLGoldenEagleHow do you find how many GID's are on each and every CID?
That would be 1How do you find how many GID's there are for each unique CID?See aboveCOUNT(*) or COUNT(GID)?Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam
how would that be 1?see sample data for ex for CID=1 it will be 3 (GID=100,132,112) |
 |
|
|
|
|
|