1

All I have the following types of rows of data in my DB

  • User 1 takes software update 1
  • User 1 performs some action on product
  • User 1 performs some action on product
  • User 1 performs some action on product
  • User 1 takes software update 2
  • User 1 performs some action on product
  • User 1 performs some action on product <-- what is the preceding software update prior to this event

I have used Lead and Lag Windows functions before so I know how to get the standard preceding event of a record. However what I want to do here is get a very specific preceding event that occurred before the event in question (i.e. the last software update that the user had performed). Is there a way to do this using Lead/Lag or an alternative way without having to self join the table on itself ?

Other data I have to hand is UserID, Date/Time of when events happen, action type (software update, login, buy, sell etc).

If more detail is required let me know.

Thanks Simon

0 Answers0