Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
datanibbler
Champion
Champion

Looking for the second-to-last booking - but...

Hi,

my issue is the following:

As part of a larger piece of code I need to do the following:

From our database I get a list of bookings - basically, whenever a part has been moved, a booking is made.

I am looking for the second-to-last because I am specifically searching for erroneous bookings which, when found, are immediately corrected, so the last booking would be the one by the person who found the erroneous booking and the one before would most probably be the one who committed the error.

<=> The challenge is that the database is of course not static and a part that was booked erroneously and found out and re-booked does of course not stop there, but further bookings of the same part are made, possibly right afterwards.

=> Just drawing from the database the second-to-last booking on that part_nr won't do as it would be possibly correct for only a very
      short timespan.

The part_numbers are unique, however, and I know the name of the person who found out about an erroneous booking on a certain part_nr., so I have to look for the booking that was made right before a booking by that person.

=> How would I do that?

Thanks a lot!

Best regards,

DataNibbler

3 Replies
Gysbert_Wassenaar

Can you post an example with some data?


talk is cheap, supply exceeds demand
datanibbler
Champion
Champion
Author

Hi,

I attach a small Excel file.

The thing is essentially quite simple: There are different bookings, each one with a complete date-time-stamp and a user_name.

I know the user_name of the one who re-booked the part upon finding it was erroneously booked (into a wrong location, that is)

=> I need the booking that was done prior to that one.

Thanks a lot!

Best regards,

DataNibbler

Gysbert_Wassenaar

See attached example


talk is cheap, supply exceeds demand