# MercoParts Analysis generated on: 4/2/2025 10:03:43 AM --- ## SQL Statement ```sql SELECT AddnlPROC.PartNumber, AddnlPROC.WC2, AddnlPROC.WC3, AddnlPROC.WC4, AddnlPROC.Machine, AddnlPROC.RunStd, MercoPart.LastMonthQty, [Lastmonthqty]*[RunStd] AS MthExtHrs, ([Lastmonthqty]*[RunStd])/22 AS DayExtHrs FROM MercoPart LEFT JOIN AddnlPROC ON MercoPart.PN = AddnlPROC.PartNumber; ``` ## Dependencies - [[Tables/MercoPart]] - [[Tables/AddnlPROC]] ## Parameters - *None* ## What it does **SQL Query Description** ========================== ### Overview This SQL query retrieves data from two tables: `MercoPart` and `AddnlPROC`. It joins the two tables based on a common column, `PartNumber`, and calculates additional statistics. ### Table Overview * **MercoPart**: This table contains information about parts managed by Merco. * Columns: * `PN`: Part Number (primary key) * `LastMonthQty`: Quantity of the part in stock for the last month * **AddnlPROC**: This table contains additional process data related to parts. * Columns: * `PartNumber` (foreign key referencing `MercoPart.PN`) * `WC2`, `WC3`, `WC4`: Additional processing values * `Machine`: Machine used for the part's production * `RunStd`: Standard run time for the part ### Query Details The query performs a left join on the two tables based on the `PartNumber` column. The results include the following calculations: * **MthExtHrs**: Extented hours worked in the last month, calculated as `LastMonthQty * RunStd` * **DayExtHrs**: Extented hours worked per day, calculated as `(LastMonthQty * RunStd) / 22` ### SELECT Statement The query selects the following columns: * `PartNumber` from both tables * `WC2`, `WC3`, and `WC4` from `AddnlPROC` * `Machine` from `AddnlPROC` * `RunStd` from `AddnlPROC` * Calculated columns: `MthExtHrs` and `DayExtHrs` ### JOIN Clause The query uses a left join to combine data from both tables. The left join ensures that all records from the `MercoPart` table are included in the results, even if there is no matching record in the `AddnlPROC` table. ```markdown FROM MercoPart LEFT JOIN AddnlPROC ON MercoPart.PN = AddnlPROC.PartNumber; ``` ### Resultset The query returns a result set with the specified columns and calculated values. The resultset includes data from both tables, but may contain null values for `AddnlPROC` columns if there is no matching record in `MercoPart`.