Access SQL Help

T

TBone

Access comes with a sample database called - Northwinds.
I am taking a database class and one of my homework
problems is to write an SQL statement for this
problem "How many different countries do we ship to?" We
are to write these queries free style SQL and not using
the Access SQL Query tool.

I thought the query should be but I get an error message.
SELECT COUNT (DISTINCT Country)
FROM Customers;

The error is "syntax error (missing operator) in query
expression ..."
 
V

Van T. Dinh

JET (the default database engine for Access) does not handle Count Distinct
this way.

You need to create a SubQuery, something like:

SELECT Count([Country])
FROM
( SELECT DISTINCT [Country]
FROM Customers
)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top