salix/db/routines/vn/procedures/orderListVolume.sql

17 lines
495 B
SQL

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`orderListVolume`(IN vOrderId INT)
BEGIN
SELECT
o.id,
o.itemFk,
i.description,
o.amount,
round(ic.cm3delivery * o.amount / 1000000,3) as volume
FROM hedera.orderRow o
JOIN item i ON i.id = o.itemFk
JOIN itemCost ic ON ic.itemFk = o.itemFk AND ic.warehouseFk = o.warehouseFk
WHERE o.orderFk = vOrderId;
END$$
DELIMITER ;