Skip to content

Instantly share code, notes, and snippets.

@catlion
Last active December 15, 2015 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save catlion/5253184 to your computer and use it in GitHub Desktop.
Save catlion/5253184 to your computer and use it in GitHub Desktop.
declare @max_mrdate datetime
declare @max_nexteval datetime
select
@max_mrdate=max(cast(mrdate as datetime)),
@max_nexteval=max(cast(nexteval as datetime))
from tblpms
where CaseNo = 'TR13-011-CRW'
select *
from tblpms where CaseNo = 'TR13-011-CRW'
and (
(med_stat is not null and cast(mrdate as datetime) = @max_mrdate)
or
(mrprocedure is not null and cast(nexteval as datetime) = @max_nexteval)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment