Re: complex querie - a follow up
- From: "Chris2" <rainofsteel.NOTVALID@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 11 Nov 2005 06:32:41 -0800
"lynn atkinson" <lynnatkinson@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:B601AF3E-7BD4-4F41-8F29-E6C37DBED3C4@xxxxxxxxxxxxxxxx
> A couple of months ago I posted a question on how to filter a
query with many
> criteria. I did get a helpful answer, but I have got myself in
another pickle
> and cannot get the suggested code to work. In addition, I have
simplified the
> database by having fewer linked tables etc.
>
> The scenario is this
> I have a training database and I need to filter a query to find
> qualified people. Whether a person is qualified or not depends on
their job
> title.
>
> Job title = support assistant needs care2 AND starndard
registration; OR
> Advanced registration only
> job title= support worker needs care3 AND standard registration;
OR advanced
> registration only
> Job title=assistant project manager needs care3 AND standard
registration
> AND management3 OR Advanced registration AND management 3
>
> I want to list all candidates who are, for example,
> support workers who are qualified; all support assistants who are
qualified
> etc etc.
>
> I have a table (progresstbl) which lists the the award (eg care 2,
care3,
> standard registration, advanced registration etc) and the
> progress (eg completed, working towards etc). An employeeinfo
table holds
> information on the candidate like the name
>
> I would like to produce 2 reports - one listing all the people
completed
> their qualifying awards and one listing all the peole compled AND
those
> working towards the qualifying awards.
>
> If it helps, the following is the sql of something that nearly
works but
> doesnt have the combination of awards ie care 2 and standard
registration
>
<code snip>
>
lynn atkinson,
I realigned query for readability (table aliases would be great,
too; but I'll skip adding those in). Also, I apologize for any
line-wrapping that may occur. I spaced everything out for
visibility purposes, but when sending to a newsgroup, that isn't
always retained. If any line-wrapping occurs, some judicious
deleting of line-breaks should restore the correct appearance.
SELECT progress.status
,progress.[candidate ID]
,progress.[start date]
,progress.award
,employeeinfo.surname
,employeeinfo.forename
,employeeinfo.title
,employeeinfo.[post/role]
,employeeinfo.Project
,employeeinfo.locality
,employeeinfo.[old contract]
,employeeinfo.[employee ID]
FROM employeeinfo
INNER JOIN
progress
ON employeeinfo.[employee ID] = progress.[employee id]
WHERE
(
((progress.status) = "completed"
OR (progress.status) = "working towards")
AND ((progress.award) = "care 2")
AND ((employeeinfo.[post/role]) = "support assistant")
AND ((employeeinfo.[old contract]) = False)
)
OR
(
((progress.status) = "completed"
OR (progress.status) = "working towards")
AND ((progress.award) = "care 3")
AND ((employeeinfo.[post/role]) = "support worker")
AND ((employeeinfo.[old contract]) = False)
)
OR
(
((progress.status) = "completed"
OR (progress.status) = "working towards")
AND ((progress.award) = "care 3"
AND (progress.award) = "management 3")
AND ((employeeinfo.[post/role]) = "assistant project
manager")
AND ((employeeinfo.[old contract]) = False)
);
------------------------------
Job title = support assistant needs care2 AND starndard
registration; OR
Advanced registration only
job title= support worker needs care3 AND standard registration; OR
advanced
registration only
Job title=assistant project manager needs care3 AND standard
registration
AND management3 OR Advanced registration AND management 3
------------------------------
Completely Untested Suggestions:
Note: In the third group, you have specified that progress.award be
both equal to "care 3" and "management 3". This cannot happen.
Try:
(
((progress.status) = "completed"
OR (progress.status) = "working towards")
AND ((progress.award) IN ("care 3", "management
3"))
AND ((employeeinfo.[post/role]) = "assistant project
manager")
AND ((employeeinfo.[old contract]) = False)
);
This can further be reduced to:
(
((progress.status) IN ("completed", "working
towards"))
AND ((progress.award) IN ("care 3", "management
3"))
AND ((employeeinfo.[post/role]) = "assistant project
manager")
AND ((employeeinfo.[old contract]) = False)
);
Remember, that's just a guess on my part at this point.
Sincerely,
Chris O.
.
- Prev by Date: Re: Running custom Excel query for Access
- Next by Date: Re: date / text criteria for query
- Previous by thread: Re: complex querie - a follow up
- Next by thread: Re: "Cannot delete from specified tables"
- Index(es):
Relevant Pages
|