How to calculate time since last event in PL/SQL?
562979May 24 2007 — edited Jun 5 2007I am facing the following problem:
I have a TABLE like this:
CUSTOMER_ID (number),
EVENT_TIME (timestamp),
IND_PURCHASE (number) # indicator 0|1 if buy
I want to calculate the time(in minutes) since the last purchase of each customer. How can I do that in PL/SQL?
Basically for each CUSTOMER_ID at each EVENT_TIME calculate CURRENT_EVENT_TIME - (LAST_EVENT_TIME where IND_PURCHASE = 1)
Your help is greatly appreciated.