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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Case statement in and or statement

Status
Not open for further replies.

renee35

MIS
Jan 30, 2007
199
I am trying to create a or statement and what I have is a case statement to handle the 2nd half of it. This is what I need to accomplish:

anyone who has at least 90 days of employment between their earliest start date of all of their jobs, and their latest end date of any of their jobs (or the end date of the report [1/1/2009 – 4/1/2009 – ETC], if the quarter start is less than their end date, use the quarter start date), but not more than 179 days worked (So that they only show up on the report once).

This is what I have so far:

select employeeid, min(startdate) as startdate, max(enddate) as enddate
from SS_HTRNJ.dbo.woworkorder
where ((enddate is null or datediff(dd, enddate, startdate) <= 90) )
or
(Case when @quarterstart < enddate then datediff(dd, @quarterstart, startdate) <= 90)))
group by employeeid


I am getting an error:

Line 21: Incorrect syntax near '<'. Which points back to the Case statement, please help!!!


Thanks a bunch!!

-T
 
YOU have to define a result for the case eg

(Case when @quarterstart < enddate then datediff(dd, @quarterstart, startdate) else 100 end) <= 90

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top