I want to get the activity_id of the 1st "email" activity that happened in between the "completed_order" activity in a different column. tried this below code but instead of getting the id of the first "email" activity, I am getting the id of "completed_order" activity.
SELECT activity_id, customer , activity, ts, case when activity = 'completed_order' and lead(activity) over (partition by customer order by ts) ='email' then activity_id end as cndn from activity_stream where customer in ( select customer where customer = 'Lehmanns Marktstand' ) order by ts 
This should be my Desired Result
https://stackoverflow.com/questions/67260653/postgressql-query April 26, 2021 at 11:56AM
没有评论:
发表评论