3 Replies Latest reply: Nov 15, 2014 6:43 AM by Gysbert Wassenaar RSS

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

    Friedrich Hofmann

      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