USE inventory;
CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `viewsupplierperencanaan` AS select `a`.`NO_MR` AS `NO_MR`,`sp`.`SUPPLIER` AS `SUPPLIER`,`p`.`NAMA` AS `DESKRIPSI` from ((`inventory`.`material_request_detil` `a` left join (select `ap`.`SUPPLIER` AS `SUPPLIER`,`apd`.`BARANG` AS `BARANG` from (`inventory`.`surat_penawaran_harga` `ap` join `inventory`.`surat_penawaran_harga_detil` `apd`) where ((`apd`.`ID_PENAWARAN` = `ap`.`NOMOR`) and (`ap`.`STATUS` = 2) and (`apd`.`STATUS` = 2)) group by `ap`.`SUPPLIER`,`apd`.`BARANG`) `sp` on((`sp`.`BARANG` = `a`.`BARANG`))) left join `inventory`.`penyedia` `p` on((`p`.`ID` = `sp`.`SUPPLIER`))) where ((`a`.`STATUS` = 1) and (`sp`.`SUPPLIER` is not null)) group by `a`.`NO_MR`,`sp`.`SUPPLIER` ;
