This project aims to improve manufacturing quality by applying Statistical Process Control (SPC). Using SQL, we analyze historical production data to calculate the Upper Control Limit (UCL) and Lower Control Limit (LCL) for product height. These limits define the acceptable range for production. Parts falling outside this range signal process issues that need correction. This data-driven approach helps maintain consistent product quality and ensures the manufacturing process runs efficiently with minimal defects.
UCL = avg_height + 3 × (stddev_height / √5)
LCL = avg_height − 3 × (stddev_height / √5)
The UCL defines the highest acceptable height for the parts, while the LCL defines the lowest acceptable height for the parts. Ideally, parts should fall between the two limits.
The data is available in the manufacturing_parts
table which has the following fields:
item_no
: the item numberlength
: the length of the item madewidth
: the width of the item madeheight
: the height of the item madeoperator
: the operating machineEDA involved exploring the manufacturing_parts table to answer key questions, such as:
Including some interesting code/features worked with
-- Flag whether the height of a product is within the control limits
SELECT
b.*,
CASE
WHEN
b.height NOT BETWEEN b.lcl AND b.ucl
THEN TRUE
ELSE FALSE
END as alert
FROM (
SELECT
a.*,
a.avg_height + 3*a.stddev_height/SQRT(5) AS ucl,
a.avg_height - 3*a.stddev_height/SQRT(5) AS lcl
FROM (
SELECT
operator,
ROW_NUMBER() OVER w AS row_number,
height,
AVG(height) OVER w AS avg_height,
STDDEV(height) OVER w AS stddev_height
FROM manufacturing_parts
WINDOW w AS (
PARTITION BY operator
ORDER BY item_no
ROWS BETWEEN 4 PRECEDING AND CURRENT ROW
)
) AS a
WHERE a.row_number >= 5
) AS b;
The result analysis are summarized as follows:
Based on the analysis, we recommend the following actions: