I’m trying to evaluate whether a user’s action is performed in relativity to another action. Both actions are marked with a timestamp.
What I want to evaluate is whether a user when she has an entry in one table e.g. A (both tables has the same ID for an individual user) has an entry in another table, B, in between the time of entry in A and 5 minutes earlier. I manage to extract time for all values
SELECT
TO_CHAR(playdatetime - 5/(24*60),'YYYY-MM-DD HH24:MI:SS') five_min_future,
TO_CHAR(playdatetime,'YYYY-MM-DD HH24:MI:SS') jetzt,
TO_CHAR(SEARCHDATE,'YYYY-MM-DD HH24:MI:SS') ses_time
I tried to make something like this:
CASE
WHEN TO_CHAR(SEARCHDATE,'YYYY-MM-DD HH24:MI:SS')
BETWEEN TO_CHAR(playdatetime - 1/(24*60),'YYYY-MM-DD HH24:MI:SS')
AND
TO_CHAR(playdatetime,'YYYY-MM-DD HH24:MI:SS')
THEN 1
ELSE 0
END timediff
but how could I get this to just check for one user and not just evaluate the row at hand?
The following query shows records that exist in both
aandb, where the record inboccurs up to 5 minutes before that ina: