This document contains the code for 5 stored procedures:
1) Counts the number of raw products for each finished product
2) Finds the highest purchase price of any raw product
3) Lists finished products that use more than 2 raw products
4) Returns the supplier name given a raw product name
5) Uses joins and grouping to retrieve aggregated data from multiple tables
This document contains the code for 5 stored procedures:
1) Counts the number of raw products for each finished product
2) Finds the highest purchase price of any raw product
3) Lists finished products that use more than 2 raw products
4) Returns the supplier name given a raw product name
5) Uses joins and grouping to retrieve aggregated data from multiple tables
This document contains the code for 5 stored procedures:
1) Counts the number of raw products for each finished product
2) Finds the highest purchase price of any raw product
3) Lists finished products that use more than 2 raw products
4) Returns the supplier name given a raw product name
5) Uses joins and grouping to retrieve aggregated data from multiple tables
BEGIN SELECT pf.codeprofini, pf.nompro, COUNT(pb.codeprobrut) AS nombre_de_bruts FROM produitFini pf LEFT JOIN composition c ON pf.codeprofini = c.codeprofini LEFT JOIN produitBrut pb ON c.codeprobrut = pb.codeprobrut GROUP BY pf.codeprofini, pf.nompro; END //
BEGIN SELECT pf.codeprofini, pf.nompro, COUNT(c.codeprobrut) AS nombre_de_bruts FROM produitFini pf LEFT JOIN composition c ON pf.codeprofini = c.codeprofini GROUP BY pf.codeprofini, pf.nompro HAVING nombre_de_bruts > 2; END //
VARCHAR(255), OUT supplier_name VARCHAR(255)) BEGIN SELECT f.rsfour INTO supplier_name FROM fournisseur f JOIN produitBrut pb ON f.numfour = pb.numfour WHERE pb.nomprobrut = product_brut_name; END //