Group By State name and employee total

Sims, John (CDC/CCHP/NCBDDD) (CTR) ayu8 at cdc.gov
Mon Mar 31 07:18:12 CDT 2008


> -----Original Message-----
> From: valentina-bounces at lists.macserve.net 
> [mailto:valentina-bounces at lists.macserve.net] On Behalf Of 
> Ruslan Zasukhin
> Sent: Monday, March 31, 2008 3:42 AM
> To: valentina at lists.macserve.net
> Subject: Re: Group By State name and employee total
> 
> On 3/31/08 6:25 AM, "barry at noodlebox.com.au" 
> <barry at noodlebox.com.au> wrote:
> 
> Hi Barry,
> 
> > How do you Group by State when counting employees?
> > 
> > Select ???(StateName), count(*) from tblEmployee Group by State
> > 
> > I want to see something like
> > 
> > Texas 73
> > California 1090
> 
> Yes, your query looks fine
> 
> Possible actually 2 cases:
> 
> 
> SELECT StateName, COUNT(*)
> FROM tblEmployee
> Group BY State
> 
> Or 
> 
> SELECT StateName, COUNT(fld)
> FROM tblEmployee
> Group BY State
> 
> 
> They differ in counting of NULL values.
> 
> 
> -- 
> Best regards,
> 
> Ruslan Zasukhin
> VP Engineering and New Technology
> Paradigma Software, Inc


Shouldn't it be

SELECT StateName, COUNT(*) FROM tblEmployee GROUP BY StateName

And not "BY State"?  Since, in the original example, StateName is not
contained in an aggregate function or the GROUP BY clause, I would
expect these queries to fail.

-John 



More information about the Valentina mailing list