Your screenshots does not match the description. From the screenshots it looks like you want
UPDATE tbl
SET IMT_Qty = ITM_Qty - Open_Qty
WHERE IMT_Qty > Open_Qty
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi team how to update the values from the below columns
condition is IMT_qty is less than the open_qty field i need to divide the differences between these two columns and update the IMT_qty column, if both the IMT_qty&open_qty are same will keep the same IMT_Qty value in the IMT_Qty column.
case when IMT_Qty < Open_Qty then IMT_Qty/Open_Qty else IMT_Qty end
Attached is the required screenshot for the output.
how to write the correct statement for update
Your screenshots does not match the description. From the screenshots it looks like you want
UPDATE tbl
SET IMT_Qty = ITM_Qty - Open_Qty
WHERE IMT_Qty > Open_Qty
Hi @Naresh y
Try this:
UPDATE TableName
SET IMT_Qty = CASE WHEN ITM_Qty = Open_Qty THEN IMT_Qty ELSE ABS(ITM_Qty - Open_Qty) END
Best regards,
Cosmog Hong
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".