View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.links
Ed Ferrero
 
Posts: n/a
Default can't change field name in query?

Hi rachael,

You need to add a Group By clause to use the COUNT function in SQL

Try something like this example (uses Northwind)

SELECT Customers.Country, Customers.Region, Count(Customers.Region) AS
CountStatus
FROM master.dbo.Customers Customers

Ed Ferrero
http://www.edferrero.com


"rachael" wrote in message
...
I'm using Microsoft Query to bring in some data. I have the query in SQL
so i
can do some groupings and count values in one of the fields. My problem is
I'm having difficulty renaming a field, so it comes back with no name at
all.
The SQL line is:

SELECT [lots of fields], Count(StudentHistory.Status) AS CountStatus

The count comes back properly, but the changed field name (i.e.,
CountStatus) doesn't appear. The field name is blank. How does this need
to
be written so the field name comes back as CountStatus?

Thanks
rachael