You are here: Re: Subquery headache with Count and GroupBy « MsSQL Server « IT news, forums, messages
Re: Subquery headache with Count and GroupBy

Posted by Robert Klemme on 11/22/05 18:05

laurenq uantrell wrote:
> I'm trying to return an integer from the following table that returns
> the number of unique cities:
>
>
> tblEmployees
> Name City
> John Boston
> Frank New York
> Jim Omaha
> Betty New York
>
> The answer should be 3.
>
> DECLARE @EmployeeCities int
>
> SELECT @EmployeeCities = SELECT ... ???
>
> How go I return one row/column into @EmployeeCities from a Count and a
> GroupBy?
>
> Headache already... Maybe it's too early...

select @EmployeeCities = select count(distinct City) from tblEmployees

Kind regards

robert

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация