2.1 KiB
2.1 KiB
SP Make Latest
Analysis generated on: 4/2/2025 10:11:48 AM
SQL Statement
SELECT Left$([Process]![PartNumber],7) AS prt, Max((UCase$(Trim$(Right$([Process]![PartNumber],1))))) AS Rev
FROM Process
GROUP BY Left$([Process]![PartNumber],7)
ORDER BY Left$([Process]![PartNumber],7), Max((UCase$(Trim$(Right$([Process]![PartNumber],1))))) DESC;
Dependencies
Parameters
- None
What it does
SQL Query Description
Purpose
This SQL query extracts the part number from a Process
table, performs some data manipulation operations on it, and returns the results in a sorted manner.
Breakdown
1. Column Selection
SELECT Left$([Process]![PartNumber],7) AS prt, Max((UCase$(Trim$(Right$([Process]![PartNumber],1))))) AS Rev
- The query selects two columns from the
Process
table:Left$([Process]![PartNumber],7)
: This extracts the first 7 characters from thePartNumber
column and assigns it an aliasprt
.Max((UCase$(Trim$(Right$([Process]![PartNumber],1))))) AS Rev
: This calculates the maximum value of the uppercased trimmed rightmost character of thePartNumber
column. The result is assigned an aliasrev
.
2. Data Manipulation
FROM Process
- The query operates on the
Process
table.
3. Grouping and Sorting
GROUP BY Left$([Process]![PartNumber],7)
ORDER BY Left$([Process]![PartNumber],7), Max((UCase$(Trim$(Right$([Process]![PartNumber],1))))) DESC;
- The query groups the results by the first 7 characters of the
PartNumber
column (Left$([Process]![PartNumber],7)
). - Finally, it sorts the grouped results in descending order based on both the first 7 characters of the
PartNumber
and the maximum value of the uppercased trimmed rightmost character.
In Summary
This SQL query extracts the part number from a table, calculates a derived column, groups the data, and returns the sorted results. The sorting is done based on two columns: the leftmost 7 characters of the part number and the maximum value of the uppercased rightmost character.