# Query12 Analysis generated on: 4/2/2025 10:08:48 AM --- ## SQL Statement ```sql SELECT [Processes by List].PartNumber, UniversalQ.GrossWt, UniversalQ.ActualWt, Left([UniversalQ]![PartNumber],7) AS PN, UniversalQ.Utilization INTO temp2 FROM [Processes by List] LEFT JOIN UniversalQ ON [Processes by List].PartNumber = UniversalQ.PartNumber; ``` ## Dependencies - [[Queries/UniversalQ]] ## Parameters - *None* ## What it does **SQL Query Description** ========================== ### Overview This SQL query retrieves data from two tables: `[Processes by List]` and `UniversalQ`. It performs a left join operation to combine rows from both tables based on a common column, `PartNumber`. ### Query Details * **Table Selection**: The query selects data from the following tables: * `[Processes by List]`: This table is the source of the data. * `UniversalQ`: This table serves as the secondary data source for the join operation. * **Join Type**: A left join (`LEFT JOIN`) is used to combine rows from both tables. In a left join, all records from the left table ( `[Processes by List]` ) are included in the result set, and matching records from the right table ( `UniversalQ` ) are appended to the left table's records. * **Join Condition**: The join operation is based on the `PartNumber` column, which exists in both tables. This ensures that only rows with a match in both tables are included in the result set. * **Selected Columns**: * `[Processes by List].PartNumber`: Retrieves the part number from the left table. * `UniversalQ.GrossWt`: Retrieves the gross weight column from the right table. * `UniversalQ.ActualWt`: Retrieves the actual weight column from the right table. * `Left([UniversalQ]![PartNumber],7) AS PN`: Truncates the part number from the left table to 7 characters using the `LEFT` function and assigns it an alias `PN`. * `UniversalQ.Utilization`: Retrieves the utilization data from the right table. * **Temporary Result Set**: The query stores the result set in a temporary table named `temp2`. This allows for further processing or analysis of the combined data without modifying the original tables. ### Example Use Case This SQL query can be used to combine data from different sources, such as parts inventory and their corresponding weights. By joining these two tables based on part number, you can easily retrieve information about each part's gross weight, actual weight, and utilization data. This combined data can then be used for further analysis or reporting. ### Code Explanation The code itself is straightforward: * The `SELECT` statement retrieves the desired columns from both tables. * The `FROM` clause specifies the left table (`[Processes by List]`) as the source of the data. * The `LEFT JOIN` clause combines rows from both tables based on the common column `PartNumber`. * The `INTO` clause assigns the result set to a temporary table named `temp2`.