Skip to content
Advertisement

Updating specific rows to values based on the count of rows in another table

I have a table RESERVED_BOOKINGS_OVERRIDDEN

and another table ALLOCATED_PRODUCTS

Now I need to update the ReservedQuant column in the ALLOCATED_PRODUCTS table based on the rows in RESERVED_BOOKINGS_OVERRIDDEN

The ReservedQuant must minus by the amount of rows found where the ALLOCATED_PRODUCTS.Date is within the RESERVED_BOOKINGS_OVERRIDDEN.on_site_from_dt and RESERVED_BOOKINGS_OVERRIDDEN.on_site_to_dt and ALLOCATED_PRODUCTS.booking_product_id = RESERVED_BOOKINGS_OVERRIDDEN.booking_product_id.

This should be the state of the data after the update:

Advertisement

Answer

Advertisement