May 20, 2010 at 9:43 am
I have some data in a table called loadit with an rxno (not unique), patient, location, filldate. There are 2 records for each rxno, but the filldate different, I only need to keep the
records with the max filldate. DO I need to do a self-join and then use the max(filldate)
May 20, 2010 at 9:50 am
you can also do something like:
with CTE as
(
SELECT rxno, patient, location, filldate, ROW_NUMBER() OVER (PARTITION BY rxno ORDER BY filldate DESC) as rowNum
)
SELECT rxno, patient, location, filldate FROM CTE WHERE rowNm = 1
May 20, 2010 at 12:13 pm
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply