I am trying to figure out how to do an if statement that will essentially calculate the stock of an item based on the dates in the tp_rental table. i was hoping to do something like
if Date_Due has an entry but Date_Returned does not then set stock -1 if Date_Due has an entry and Date_returned has an entry entered then set stock +1 See below for my attempt, not sure if i need a join here?
update title_platform
set Stock = case
when tp_rental.Date_Returned is not null then stock -1
else stock +1
end
Not sure if i am going about this the right way, any help would be greatly appreciated.
Thank you

Aucun commentaire:
Enregistrer un commentaire