Select max(date_field) into Max_Date from Contacts_Table where Contact_ID =
.x

Select max(date_field) into Prev_Date from Contacts_Table +
 where Contact_ID = .x and Date_Field < .Max_Date

Assuming there is a client table separate from contacts, it would drive the
cursor.
Even better, I would think this could be done with a view.

Ben


On Sat, Mar 2, 2013 at 6:41 PM, Patti Jakusz <[email protected]> wrote:

> Is there anything in Rbase similar to LAG, where you can compare a field
> in one row to a field in the previous row of a table?  I'm always having to
> write programs where it would be so handy to just have a function like in
> SPSS and Oracle.
>
> My current task is one where I have a table of client contacts.  I have to
> count the number of days between certain types of contacts and include them
> on a report if the number of days in between is over 60.
>
> All I can think to do is:
> declare a cursor
> read the 1st row, save the client contact date in a variable
> read the 2nd row and subtract this contact date from the one stored in the
> prev variable
> save the result in a new field in the 1st row
> continue the same procedure with all the rows
> at the end of file, compare the last date to the date of the report.
>
> There's gotta be an easier way.
> Patti
>
>

Reply via email to