Combining COUNT and DISTINCT

  • Thread starter Thread starter Dave Holmes
  • Start date Start date
D

Dave Holmes

My SQL is a little shaky: is there a way to combine COUNT and
DISTINCT, that is to get a count of distinct values returned in a
query?

Right now I'm doing

SELECT COUNT(xyz) FROM (
SELECT DISTINCT(xyz) FROM Table
)

Thanks!
 
Dave said:
My SQL is a little shaky: is there a way to combine COUNT and
DISTINCT, that is to get a count of distinct values returned in a
query?

Right now I'm doing

SELECT COUNT(xyz) FROM (
SELECT DISTINCT(xyz) FROM Table
)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

In Access (JET) SQL the Count(Distinct ) function is not available.
You'll have to continue using your work-around. But, Distinct is not a
function it is a predicate:

SELECT DISTINCT ColumnName FROM TableName

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQIWhAoechKqOuFEgEQL88wCdEWvSKcbQJ/RBIkIBivyMo5UeUY8An3oU
4SuA6O8DCWWp9zz98VHXvaJa
=CM6d
-----END PGP SIGNATURE-----
 
Back
Top