-1
I have a table called transferencia
that has data on the movement of a guest in a hotel, for example
The table has no date of departure, so the date of departure is the data_entrada
in which the transferencia
is equal to transferencia + 1
.
I need to make a query that returns an extra column with the date of exit described in the paragraph above and in case the last transferencia
be equal to null
, should return the current number of days, considering the current date of the consultation (in this case today, that is why the guest is still staying). If the value of the last record of transferencia
be it <> null
, is why the guest has already left and the system has calculated the amount of days he stayed.
My DBDS is Firebird 2.5
I didn’t understand your explanation after all x is never mathematically equal to x+1. In your example the date of exit is 07/01/2019 or 08/01/2019? For the data presented try to put what the expected result.
– anonimo
Why the departure date has to be the next record, not the input data_but the qtde_days column?
– Weiner Lemes