Hello,
I want to pull only the last 2 dates (TB.FLDDATE) from the TUBER table. Do you have any insight on how to do this on the below query?
-----------------------------------------------------------
SELECT H.FLDEXPOSURE,EX.FLDDESCR,E.FLDID,E.FLDLNAME, E.FLDFNAME, E.FLDADD1, E.FLDCITY,E.FLDSTATE,E.FLDMAILSTOP,E.FLDEMAIL,E.FLDHOMEPHON,
TBLAST = CONVERT(VARCHAR(10),TB.FLDDATE,101),
TB.FLDMMREACT,
TBSS = CONVERT(VARCHAR(10),TBSS.FLDDATE,101)
FROM EMPLOYEE E INNER JOIN EXPHIST H ON E.FLDREC_NUM = H.FLDEMPLOYEE
INNER JOIN EXPOSURE EX ON EX.FLDCODE = H.FLDEXPOSURE
LEFT OUTER JOIN TUBER TB
ON TB.FLDEMPLOYEE = E.FLDREC_NUM
AND TB.FLDDATE <= getdate()
LEFT OUTER JOIN PHYSLOG TBSS
ON TBSS.FLDEMPLOYEE = E.FLDREC_NUM
AND TBSS.FLDDATE <= getdate() AND TBSS.FLDTYPE = 'TBSS'
WHERE
E.FLDCOMP = @COMP AND
H.FLDEXPOSURE = @EXPOSURE
Anu