# Util Make Select 1b Analysis generated on: 4/2/2025 10:14:46 AM --- ## SQL Statement ```sql SELECT Left$([PartNumber],7) AS prt, Right$([PartNumber],1) AS Rev, Process.* INTO [Util Selection 1] FROM Process WHERE (((Process.MetalType)=[Forms]![Utilization]![Combo12]) AND ((Left$([PartNumber],1))="9" Or (Left$([PartNumber],1))="8" Or (Left$([PartNumber],1))="7")) ORDER BY Left$([PartNumber],7), Right$([PartNumber],1) DESC; ``` ## Dependencies - [[Tables/Process]] ## Parameters - [Forms]![Utilization]![Combo12] (Empty) ## What it does **SQL Query Description** ========================== This SQL query retrieves specific data from the `Process` table based on certain conditions and formats the output. ### Query Breakdown #### 1. Select Statement The query selects all columns (`*`) from the `Process` table, but only for rows that meet the specified conditions. ```markdown SELECT Left$([PartNumber],7) AS prt, Right$([PartNumber],1) AS Rev, Process.* ``` - `Left$([PartNumber],7)` extracts the first 7 characters from the `PartNumber` column and assigns it to a new column named `prt`. - `Right$([PartNumber],1)` extracts the last character from the `PartNumber` column and assigns it to a new column named `Rev`. - `Process.*` selects all columns (`*`) from the `Process` table. #### 2. WHERE Clause The query filters rows based on two conditions: ```markdown WHERE (((Process.MetalType)=[Forms]![Utilization]![Combo12]) AND ((Left$([PartNumber],1))="9" Or (Left$([PartNumber],1))="8" Or (Left$([PartNumber],1))="7")) ``` - `((Process.MetalType)=[Forms]![Utilization]![Combo12])` filters rows where the value in the `MetalType` column matches the value in the `Combo12` field of the `Utilization` form. - `(Left$([PartNumber],1))="9" Or (Left$([PartNumber],1))="8" Or (Left$([PartNumber],1))="7"` filters rows where the first character of the `PartNumber` column is either "9", "8", or "7". #### 3. INTO Clause The query creates a new table named `[Util Selection 1]` to store the filtered data. ```markdown INTO [Util Selection 1] ``` #### 4. ORDER BY Clause The query sorts the output by two columns: - `Left$([PartNumber],7)` sorts the values in ascending order based on the first 7 characters of the `PartNumber` column. - `Right$([PartNumber],1)` sorts the values in descending order based on the last character of the `PartNumber` column. ```markdown ORDER BY Left$([PartNumber],7), Right$([PartNumber],1) DESC; ``` This ordering means that rows with more characters at the beginning (`Left`) will come first, and rows with different characters at the end (`Right`) will be sorted in descending order.