Re: Query Question
- From: Ed Murphy <emurphy42@xxxxxxxxxxxx>
- Date: Thu, 18 Jan 2007 12:16:55 -0800
Nate wrote:
I am using a table, called 'dashboard', to track employee evaluations.
There are many columns in the table, some of which are populated with
one of four responses:
"Meets Expectations", "Below Expectations", "Not Observed", "Policy
Violation"
I would like to create a query that will search for any employee that
has two "Below Expectations" in the SAME column in a span of 30 days.
I was thinking of using CONTAINS, but that would require me specifying
EVERY one of the evaluation critera (live_1, live_2.. all the way to
live_8.. then review_1, review_2... review_11)
How would you do it with CONTAINS?
If you change 'live_1', etc. from columns to values within a single
column, then you can do something like this:
select distinct d.employee
from dashboard d
join dashboard d2
on d.employee = d2.employee
and d.criterion = d2.criterion
and d.cr_date < d2.cr_date
where d.rating = 'Below Expectations'
and d2.rating = 'Below Expectations'
and d2.cr_date <= -- 30 days past d.cr_date
Otherwise, I guess you would need to do something like this:
select distinct employee from (
-- similar logic for live_1
union
-- similar logic for live 2
-- etc.
) as lumberghs
.
- References:
- Query Question
- From: Nate
- Query Question
- Prev by Date: Re: NVARCHAR Search Problem using LIKE
- Next by Date: Re: Query which calculates a field value based on previous row's values
- Previous by thread: Query Question
- Next by thread: delete old files
- Index(es):