OUTER APPLY (SELECT TOP 1
ClaimNo, ClaimLineNo, ProviderID, AgreementID, CampusID, Version, BenefitID, SvcClass, SetNo, SeqNo
FROM #Claimlines CL
WHERE
E.Episodeid = CL.Episodeid
AND CL.Admitdate IS NOT NULL
AND CL.Dischargedate IS NOT NULL
AND CL.Facilitylevel IS NOT NULL
AND CL.Dischargedate <=
(
SELECT MIN(Dischargedate)
FROM #Claimlines
WHERE Episodeid = CL.Episodeid
AND Admitdate IS NOT NULL
AND Dischargedate IS NOT NULL
AND Facilitylevel IS NOT NULL
)
ORDER BY
CL.SetNo,
CL.SeqNo,
CL.ClaimNo,
CL.ClaimLineNo
) CL
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
also useful for this ..
e.g.