This is an example of the table that i'm working with (24hour system)
|ID |Name |Department |InOutID|Date | Hours | Minutes|
________________________________________________________________________
0123 | Phil Jones | security |1 |2018-07-07| 7 |30
________________________________________________________________________
0123 | Phil Jones | security |2 |2018-07-07| 10 |30
_________________________________________________________________________
0123 | Phil Jones | security |1 |2018-07-07| 13 |30
_________________________________________________________________________
0123 | Phil Jones | security |2 |2018-07-07| 17 |00
i'm working with a scoring system database so basically what i need to do is verify the IdInOut
column if it has 1 then its an entry if its 2 then its a exit and i should calculate the real amount of time that the epmloyee has spent in the office( the table is ordered by Date,Hours,Minutes desc) normally IdInOUt should be like this
|IDInOut|
_________
2
_________
1
_________
2
_________
1
.....
basically what i need to do is set a cursor pointing at the first row and another cursor pointing at the second row and for every iteration i subsrtact hours and minutes of the second cursor from the first cursor and store them into a variable then use it afterward SO FAR SO GOOD but there is a problem with this previous table it's the following:
|ID |Name |Department |InOutID|Date | Hours | Minutes|
________________________________________________________________________
0123 | Phil Jones | security |1 |2018-07-07|7 |30
________________________________________________________________________
0123 | Phil Jones | security |1 |2018-07-07|7 |32
_________________________________________________________________________
0123 | Phil Jones | security |2 |2018-07-07|10 |30
_________________________________________________________________________
0123 | Phil Jones | security |1 |2018-07-07|13 |30
_________________________________________________________________________
0123 | Phil Jones | security |2 |2018-07-07|17 |00
there are successive rows with the same IdInOut which represents a problem since my method of work is that with every iteration i mentioned previously every cursor jumps with 2 row but when this case occurs every cursor should jump with only one row in which case i didn't find the solution :/ i Know the explanation is pretty long but i'm really stuck here any help is welcomed