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

17 lines
499 B
SQL

DELIMITER $$
CREATE OR REPLACE DEFINER=`vn-admin`@`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 ;