DROP TABLE IF EXISTS `ecart_view`;
CREATE VIEW `ecart_view` AS 
select `i`.`code_a_barre` AS `code_a_barre`,(sum(`s`.`stock_inventaire`) - `i`.`stock_theorique`) AS `ecart`,
        `s`.`position` AS `position` from (`stock` `s` join `inventaire` `i`) where (`i`.`code_a_barre` = `s`.`code_a_barre`) group by `i`.`code_a_barre` having (`ecart` <> 0);