In SQL , i want to retrieve the first three persons (marked with a tick) because they have activities that follow each other (FR, ISRO, VIS, REC) in sequence order dates. The last two persons (4 and 5) must not appear because 4 starts with DC and 5 has DE as the second last activity instead of VIS.
Please note that there can be other activities in between the history of these persons. But the idea is that if there is FR and after that it is followed by ISRO and after that by VIS and after that by REC, then this person must show up. NB (even if there might be other activities between them.
Please help with the code.
The pseudocode is:
SELECT Person.Name
FROM Person LeftJoin History On Person.person_id = History.person_id
Where ActivityName = FR followed-by ISRO followed-by VIS followed-by REC
even if there can be other activities between them.
Yeah it is ok , i just need the skeleton SQL code to select an item , and make sure it followed by something(FR), and followed by something(ISRO) , and followed by something(VIS), and followed by something(REC) using the sequence order date to compare them.
This information is in our company server, it look exactly like what i put on the picture, all i need is skeleton code of selecting items satisfying the condition that they are preceded with other items.
and all we need is for you to provide sample data to try it out on our server. or give us access to your server its very simple. provide sample data you have attached as a picture in the following format
insert into #bafanabafana
select 1, 'jane' 'Fr', '01.01.2019' union
Why is that so hard for you to do that? In order for folks to answer you question they cant use the data presented in a picture. They will have to recreate that data from scratch.
You know that i cannot give a community access to private and corporate information, on my last post you answered me very well with a skeleton code, that i went on and use and it worked.
You need to understand. We are volunteering to write code for you, to solve your problem, and we do it for many other people during the day too. I just don't have time to create sample data for everyone's issue.
You expect each of us to do it for you. But, if it's your issue, and you don't do it, then how important is it really?