CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `bi`.`last_Id_Cubo` AS SELECT `C`.`Id_Compra` AS `Id_Compra`, `C`.`Id_Article` AS `Id_Article`, `tr`.`warehouse_id` AS `warehouse_id`, `C`.`Id_Cubo` AS `Id_Cubo`, `C`.`Packing` AS `Packing` FROM ( ( `vn2008`.`Compres` `C` JOIN `vn2008`.`Entradas` `E` ON(`C`.`Id_Entrada` = `E`.`Id_Entrada`) ) JOIN `vn2008`.`travel` `tr` ON(`E`.`travel_id` = `tr`.`id`) ) WHERE `C`.`Id_Cubo` IS NOT NULL AND `C`.`Id_Cubo` <> '--' AND `tr`.`landing` > `util`.`VN_CURDATE`() - INTERVAL 18 MONTH ORDER BY `C`.`Id_Compra` DESC