
CREATE 
     OR REPLACE ALGORITHM = UNDEFINED 
    DEFINER = `root`@`%` 
    SQL SECURITY DEFINER
VIEW `vn`.`ticketGetVolume` AS
    SELECT 
        `s`.`ticketFk` AS `ticketFk`,
        `t`.`routeFk` AS `routeFk`,
        `s`.`id` AS `saleFk`,
        `t`.`shipped` AS `Fecha`,
        (((`s`.`quantity` * `r`.`cm3`) * `i`.`compression`) / 1000000) AS `volume`
    FROM
        (((`vn`.`sale` `s`
        JOIN `vn`.`item` `i` ON ((`i`.`id` = `s`.`itemFk`)))
        JOIN `vn`.`ticket` `t` ON ((`t`.`id` = `s`.`ticketFk`)))
        JOIN `bi`.`rotacion` `r` ON (((`r`.`Id_Article` = `s`.`itemFk`)
            AND (`r`.`warehouse_id` = `t`.`warehouseFk`))));

