Friday, February 17, 2012

Counting occurences

Hi,
Can anyone tell me how I would produce a table that holds just e.g. the
countries that occur more than once in another table?
This is what I have:
SELECT
city.country, count(*) as count
FROM city
GROUP BY city.country having count > 1;
But this gives me a table with 2 columns which is not what I want!
Help required and appreciated.
Hi,
Try the staging table method mentioned in:
'INF: How to Remove Duplicate Rows From a Table'
http://support.microsoft.com/?id=139444
Dinesh
SQL Server MVP
--
SQL Server FAQ at
http://www.tkdinesh.com
"M McEvoy" <mmcevoy@.iolfree.ie> wrote in message
news:c8lpvv$5n0$1@.kermit.esat.net...
> Hi,
> Can anyone tell me how I would produce a table that holds just e.g. the
> countries that occur more than once in another table?
> This is what I have:
> SELECT
> city.country, count(*) as count
> FROM city
> GROUP BY city.country having count > 1;
> But this gives me a table with 2 columns which is not what I want!
> Help required and appreciated.
>

No comments:

Post a Comment