Excluding values from a query (1 Viewer)

solnajeff

Registered User.
Local time
Today, 15:55
Joined
May 22, 2007
Messages
33
Hi

I am trying to create a query that will show only trainees who have not completed a test.

The attached relationship produces a query that does the opposite, i.e. only trainees from a particular school who have completed a specified test.

I cannot work out how to exclude trainees rather than include them.

I would appreciate any advice.

Regards


Jeff
 

Attachments

  • Relationship.png
    Relationship.png
    15.9 KB · Views: 72

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:55
Joined
May 7, 2009
Messages
19,230
you can use SQL view:

select tblTrainee.* from tblTrainee Left Join tblTestResults on tblTestResults.TraineeId = tblTrainee.TraineeID Where TblTestResult.TraineeID Is Null;
 

solnajeff

Registered User.
Local time
Today, 15:55
Joined
May 22, 2007
Messages
33
Hi

Thanks for the advice, unfortunately I cannot get it to work.

I have made up a sample to illustrate my problem and the query returns the records showing completed tests matching the criteria. However I am trying to find out how to show those trainees who have not yet completed the relevant test, i.e the inverse of the result I have.

Unfortunately I can only get it to show zero records.

Regards

Jeff
 

Attachments

  • Sample Query.accdb
    688 KB · Views: 81

jdraw

Super Moderator
Staff member
Local time
Today, 08:55
Joined
Jan 23, 2006
Messages
15,379
Try this query-- what arnelgp advised

Code:
SELECT tblTrainee.TraineeID, tblTrainee.SchoolID, tblTestResult.TraineeID
FROM tblTrainee LEFT JOIN tblTestResult ON tblTrainee.TraineeID = tblTestResult.TraineeID
WHERE (((tblTestResult.TraineeID) Is Null));
 

solnajeff

Registered User.
Local time
Today, 15:55
Joined
May 22, 2007
Messages
33
Hi

Thanks for the reply.

I finally managed to make it work but did need to use an additional query because the result table requires a specific Test ID and Test Number.

Once again many thanks

Regards

Jeff
 

jdraw

Super Moderator
Staff member
Local time
Today, 08:55
Joined
Jan 23, 2006
Messages
15,379
Can you describe in simple English (not SQL and not database terms) what is the purpose of this proposed query?
 

Users who are viewing this thread

Top Bottom