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

17 lines
493 B
MySQL
Raw Permalink Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`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 ;