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 |
|
visa123
Yak Posting Veteran
54 Posts |
Posted - 2010-10-15 : 08:51:39
|
| I have a Distinct all the values for cid based.below are the valuescid cname dest1 xxx it1 yyy it2 zzz ctSelect Distinct * from tablenameBut the count not coming properly bec of dest cname fieldany help plsVisa.G |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2010-10-15 : 09:06:26
|
| SELECT cid, cname, dest, COUNT(*) FROM tableGROUP BY cid, cname, dest- LumbagoMy blog (yes, I have a blog now! just not that much content yet) -> www.thefirstsql.com |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-10-17 : 02:28:46
|
i think op meantSELECT t.*,t1.CntFROM Table tINNER JOIN (SELECT cid,COUNT(*) AS Cnt, MIN(cname) AS MinName FROM Table GROUP BY cid)t1ON t1.cid = t.cidAND t1.MinName=t.cname ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|