Then you will need to do something like:

SELECT PatNumbr, Service, CptCode, D_O_S FROM OldDets OD1 +
    WHERE PatNumbr = .vPatNumbr AND NOT EXISTS +
    (SELECT * FROM OldDets OD2 WHERE OD2.PatNumbr = OD1.PatNumbr AND 
OD2.Service = OD1.Service AND OD2.D_O_S > OD1.D_O_S)

This will probably be somewhat slower, but will get you what you want.  It 
assumes the same service can only occur once per patient per date.
--
Larry


________________________________
From: mjsmd <[email protected]>
To: RBASE-L Mailing List <[email protected]>
Sent: Sun, October 25, 2009 10:00:23 PM
Subject: [RBASE-L] - Re: Is there a better way to get the list of most recent 
items?


In my example, cptcodes change over the course of several years, but the name 
of the service does not. What I would like is for Rbase to return the value of 
the cptcode that was associated with (in the same row as) the most recent 
service.

Michael Sinclair, MD
www.epilution.com
(\__/)
(='.'=)
(")_(")


On Oct 25, 2009, at 9:29 PM, Lawrence Lustig <[email protected]> wrote:


<<
>I think this will work! Is it possible to add another column (cptcode) to what 
>is displayed without adding it to the group by clause?
>>>
>
>
>All columns must be EITHER included in the GROUP BY clause OR ELSE wrapped in 
>a aggregate function (MIN, MAX, COUNT, STD, AVG, or LISTOF).  Otherwise, how 
>would R:Base know which of several values to report back to you?
>--
>Larry
>
>
>>>
>>
>>
>>

Reply via email to