Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / SQL Server / ADP / May 2008

Tip: Looking for answers? Try searching our database.

Identifying those who have not been appraised

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sandy - 12 May 2008 15:24 GMT
I have a database to log annual appraisals. It holds details of each
appraisal, including date, and the year of the appraisal, recorded as
'2005/6', '2006/7' etc. I wish to identify all those who have not had an
appraisal in 2007/8. The SQL below, of course, does not just identify those
people who were appointed before 1 April 2007 and who have not been appraised
in 2007/8. How do I restict it to those people? Any help much appreciated.
Sandy

SELECT tblConsultants.MainSite, tblConsultants.ConsultantStatus, [Surname] &
", " & [Title] & " " & [Initials] AS Name, tblConsultants.StartDate,
tblConsultants.Surname, tblAppraisals.AppraisalYr
FROM tblAppraisers RIGHT JOIN (tblConsultants LEFT JOIN tblAppraisals ON
tblConsultants.ConsultantID = tblAppraisals.ConsultantID) ON
tblAppraisers.AppraiserID = tblAppraisals.AppraiserID
WHERE (((tblConsultants.ConsultantStatus)="Current") AND
((tblConsultants.StartDate)<#4/1/2007#) AND ((Exists (SELECT ConsultantID
FROM tblAppraisals
WHERE tblAppraisals.AppraisalYr<>"2007/8"))=True))
ORDER BY tblConsultants.MainSite, [Surname] & ", " & [Title] & " " &
[Initials];
Sylvain Lafontaine - 12 May 2008 17:22 GMT
First, this newsgroup is about ADP and SQL-Server and has nothing with doing
regular queries in Access.  You should ask this kind of question in a more
appropriate newsgroup such as m.p.access.queries.

Second, I really don't understand the purpose here of making a Right Join
between the tables tblConsultants and tblAppraisals.  In the case that you
would want to keep both of these two JOIN, you'll have to give an alias to
the table tblAppraisals the second time it's jointed.

Finally, as to your problem, you have two problems with your subquery here.
First, from your description of the problem, I suppose that you should use
the Not Exists statement instead of an Exists statement (or replace True
with False).  BTW, the value returned by the Exists() statement is already a
logical (True/False) value; so you don't have to make a final comparaison
with « = True » to use it in your filtering WHERE statement. Second, you
must etablish a relationship between the main query and the subquery;
something like:

SELECT tblConsultants.MainSite, tblConsultants.ConsultantStatus, [Surname] &
", " & [Title] & " " & [Initials] AS Name, tblConsultants.StartDate,
tblConsultants.Surname, tblAppraisals.AppraisalYr

FROM tblConsultants LEFT JOIN tblAppraisals ON tblConsultants.ConsultantID =
tblAppraisals.ConsultantID

WHERE tblConsultants.ConsultantStatus = "Current"
   And tblConsultants.StartDate < #4/1/2007#

   And Not Exists (
       SELECT ConsultantId FROM tblAppraisals
       WHERE tblAppraisals.AppraisalYr <> "2007/8"
           And tblAppraisals.ConsultantId = tblConsultants.ConsultantId
   )

ORDER BY tblConsultants.MainSite, [Surname] & ", " & [Title] & " " &
[Initials];

Notice the « AND tblAppraisals.ConsultantId = tblConsultants.ConsultantId »
statement that I've added inside the subquery.

Signature

Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: sylvain aei ca (fill the blanks, no spam please)

>I have a database to log annual appraisals. It holds details of each
> appraisal, including date, and the year of the appraisal, recorded as
[quoted text clipped - 19 lines]
> ORDER BY tblConsultants.MainSite, [Surname] & ", " & [Title] & " " &
> [Initials];
Sandy - 13 May 2008 21:01 GMT
THank you very much Sylvain. My apologies for choosing the wrong discussion
group.

> First, this newsgroup is about ADP and SQL-Server and has nothing with doing
> regular queries in Access.  You should ask this kind of question in a more
[quoted text clipped - 59 lines]
> > ORDER BY tblConsultants.MainSite, [Surname] & ", " & [Title] & " " &
> > [Initials];

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.