ALTER TABLE `orderitem` ADD COLUMN `discount`  double(5,2) NOT NULL DEFAULT 0.00 AFTER `unitPriceExGST`;
CREATE INDEX `discount` ON `orderitem`(`discount`) USING BTREE ;

UPDATE orderitem
SET discount = ROUND(((unitPrice * qtyOrdered) - totalPrice) / (unitPrice * qtyOrdered), 2) * 100, updated = updated
WHERE  active = 1
AND taxFree = 0
AND (unitPrice * qtyOrdered) > totalPrice
