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 |
|
Exir
Posting Yak Master
151 Posts |
Posted - 2009-12-29 : 03:13:18
|
| HiI have a table like this:code - color - weight100 - red - 50100 - blue - 54100 - pink - 70200 - red -120200 - yellow - 150200 - brown - 130200 - blue -120300 - red - 34i want to write a command to show how many goals there are in the table. each code is belong to one goal and for this example it should return threeI thought it should be something like this: select count(select count(*) from table group by code)but it doesnt work and the outer select can not count the rows of inner selectplease give me some guidance |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-12-29 : 03:26:08
|
| select count(counting) from(select count(*) as counting from table group by code) as tMadhivananFailing to plan is Planning to fail |
 |
|
|
Exir
Posting Yak Master
151 Posts |
Posted - 2009-12-29 : 03:38:25
|
| Thanks alot |
 |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2009-12-29 : 04:44:28
|
| Try this tooselect top 1 count(*) from table group by codeWITH Rollup order by codeSenthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-12-29 : 06:06:45
|
quote: Originally posted by senthil_nagore Try this tooselect top 1 count(*) from table group by codeWITH Rollup order by codeSenthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/
This is incorrect and also most ineffecient MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|