I am trying to do an update statement that will update all of my parts and insert the max number of the qty ordered minus the qty recieved. If I received more than I ordered the the number will be a negative which is not correct, so I would like to have it insert a zero if zero is higher than the result of my on order.
I tried the statement below in SQL Server 2000 and received message that Greatest is not a recognized function. I also tried max but this too had issues.
update f_parts set PA_on_order=(Select sum(greatest(FPO_ORDER_QTY-FPO_RECEVIED,0)) FROM F_PO_LINES , F_PO_HEADERS WHERE PO_PK=FPO_PO_FK AND FPO_PART_CODE=PA_CODE AND (PO_CLOSED=0))
Thanks!
I tried the statement below in SQL Server 2000 and received message that Greatest is not a recognized function. I also tried max but this too had issues.
update f_parts set PA_on_order=(Select sum(greatest(FPO_ORDER_QTY-FPO_RECEVIED,0)) FROM F_PO_LINES , F_PO_HEADERS WHERE PO_PK=FPO_PO_FK AND FPO_PART_CODE=PA_CODE AND (PO_CLOSED=0))
Thanks!