Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi guys,
I have a table that represents people and month and year they are employed. It looks like this:
Employee | Month | Year |
---|---|---|
1 | Jan | 2015 |
2 | Jan | 2015 |
3 | Jan | 2015 |
1 | Feb | 2015 |
1 | Mar | 2015 |
I want to set a flag to a person that was employed last month and not employed next month. For example if a person is not in Feb or March (like Employee 2 and 3 ) they left their job, so i want to put a flag to person 2 and 3 in Jan that they are not emplyed later. How do i compare person and month in script?
Thanks in advance,
Jacek
Hi Jacek,
I would do it in following way:
1. Make date using year and month from your table.
2. Create another table with Employee and max date.
Find all employes who doesn't work any more. Max date for each employe compare to current date. In case of max date is in current months flag not needed in another case flag needed.
3. left join to original table records with flag only.
Hope it is clear.