Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
HiI have table called EMPLOYEE has the following data:Table: ESTempID estID246 539214 539178 539233 538244 539Table: EMPLOYEEempID estID updDT246 539 2004-04-22214 539 2001-01-17178 539 2001-01-30178 539 2004-04-22233 538 2001-01-17244 539 2001-01-30244 539 2004-04-30From the above data structure based on estID(let's say 539), I need to list employees with latest updDT, like this:Expected output:(for estID=539)246 539 2004-04-22214 539 2001-01-17178 539 2004-04-22244 539 2004-04-30The idea is each EMP due for next update every 3 years. So I would like to list lastdate over 2yrs and less than 3yrs. I have tried something like this:SELECT DISTINCT b.empID,b.updDTFROM EST a,EMPLOYEE bWHERE a.estID=539 and a.empID=b.empID andb.updDT < dateadd(year,-2,'12/12/2006')But I'm still getting EMP's 178,244 repeated twice.Please help meThanksBob