Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Distinct count problems

Status
Not open for further replies.

douggy

Technical User
Jan 18, 2001
78
GB
HI there,

I am running the following query in Access to get a distinct count. It produces the right results however when I try and save the query it crashes access. Can anyone see the problem with it.

Regards Mark

QUERY

SELECT Count(Client_ID) AS CountOfClientID FROM
(SELECT DISTINCT TblClassAttendance.Client_ID as
FROM TblClasses INNER JOIN TblClassAttendance ON TblClasses.ClassId = TblClassAttendance.ClassId
WHERE (((TblClasses.ClassDate) Between [start date] And [end date])));
 
Looks like NAME was missing. I doubt that its the whole story but it got it working here.

SELECT Count(Client_ID) AS CountOfClientID FROM
(SELECT DISTINCT TblClassAttendance.Client_ID as <b> NAME </B> FROM TblClasses INNER JOIN TblClassAttendance ON TblClasses.ClassId = TblClassAttendance.ClassId
WHERE (((TblClasses.ClassDate) Between [start date] And [end date])));

Herman
Say no to macros
 
Why not simply this ?
SELECT Count(*) AS CountOfClientID FROM
(SELECT DISTINCT A.Client_ID
FROM TblClasses AS C INNER JOIN TblClassAttendance AS A ON C.ClassId = A.ClassId
WHERE C.ClassDate Between [start date] And [end date]) AS D;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top