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 |
|
allan8964
Posting Yak Master
249 Posts |
Posted - 2011-12-07 : 13:50:42
|
| Hi there,If I run select count(Country) from tablegroup by Countrythen I get sum of each country, like this 3 (for America)4 (for UK)5 (for Japan)but how can I know how many groups of countries in there (here there are three)? |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2011-12-07 : 14:00:08
|
| Are you looking for @@ROWCOUNT? |
 |
|
|
allan8964
Posting Yak Master
249 Posts |
Posted - 2011-12-07 : 23:06:42
|
| well, @@ROWCOUNT is a way, anything else? Thanks. |
 |
|
|
raguyazhin
Posting Yak Master
105 Posts |
Posted - 2011-12-07 : 23:37:07
|
| Select Count(*) From (select Count(Country) As CCount from (Select 'America' As CountryUnion AllSelect 'America'Union AllSelect 'America'Union AllSelect 'UK'Union AllSelect 'UK'Union AllSelect 'Japan'Union AllSelect 'Japan'Union AllSelect 'Japan'Union AllSelect 'India')Vgroup by Country)VV |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-08 : 01:34:09
|
| [code]select count(distinct Country) from table[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
allan8964
Posting Yak Master
249 Posts |
Posted - 2011-12-08 : 11:56:53
|
quote: Originally posted by visakh16
select count(distinct Country) from table ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
That's what I am looking for!!! Thank you visakh16!!! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-08 : 12:26:54
|
| wc------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|