# Processes by material Analysis generated on: 4/2/2025 10:05:56 AM --- ## SQL Statement ```sql SELECT Left$([PartNumber],7) AS prt, Trim$(Right$([PartNumber],1)) AS Rev, Process.PartNumber AS PartNumber, Process.MetalType, Left$([PartNumber],1) AS stfdsvgde FROM Process WHERE (((Process.MetalType)=[Forms]![Material Upgrade]![txtMaterial]) AND ((Left$([PartNumber],1))="2" Or (Left$([PartNumber],1))="9" Or (Left$([PartNumber],1))="8" Or (Left$([PartNumber],1))="1")) ORDER BY Left$([PartNumber],7), Trim$(Right$([PartNumber],1)) DESC , Left$([PartNumber],1); ``` ## Dependencies - [[Tables/Process]] ## Parameters - [Forms]![Material Upgrade]![txtMaterial] (Empty) ## What it does **SQL Query Description** ===================================== This SQL query retrieves specific data from a database table named `Process` based on certain conditions. The query uses various string manipulation functions and filters the results to produce a list of part numbers, metal types, and other relevant information. ### Key Functions Used * `Left$([PartNumber],7)`: Returns the first 7 characters of the `PartNumber` column. * `Trim$(Right$([PartNumber],1))`: Removes the last character from the right side of the `PartNumber` column and trims any leading or trailing whitespace. * `Process.PartNumber AS PartNumber`: Selects the `PartNumber` column from the `Process` table and assigns it an alias `PartNumber`. * `Left$([PartNumber],1)`: Returns the first character of the `PartNumber` column. ### Filtering Conditions The query applies several conditions to filter the results: 1. **Metal Type**: The metal type must match the value in the `[Forms]![Material Upgrade]![txtMaterial]` field. 2. **Part Number Prefix**: The part number prefix must be either "2", "9", "8", or "1" (in any case). ### Sorting and Ordering The results are sorted by: 1. `Left$([PartNumber],7)` in ascending order 2. `Trim$(Right$([PartNumber],1))` in descending order 3. `Left$([PartNumber],1)` in ascending order ### Output The query returns a list of part numbers, metal types, and other relevant information, sorted according to the specified criteria. **Example Output** ------------------- | prt (7-character substring) | Rev (last character removed) | PartNumber | MetalType | | --- | --- | --- | --- | | XXXXXXXX | 1 | XYZ1234569 | Material A | | XXXXXXXX | 2 | ABC2345678 | Material B | | ... | ... | ... | ... | Note that the actual output will depend on the data in the `Process` table and the values in the `[Forms]![Material Upgrade]![txtMaterial]` field.