| 
 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] 
 |