54 lines
2.1 KiB
Markdown
54 lines
2.1 KiB
Markdown
# SP Make Latest
|
|
Analysis generated on: 4/2/2025 10:11:48 AM
|
|
---
|
|
## SQL Statement
|
|
```sql
|
|
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
|
|
- [[Tables/Process]]
|
|
## 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
|
|
```sql
|
|
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 the `PartNumber` column and assigns it an alias `prt`.
|
|
* `Max((UCase$(Trim$(Right$([Process]![PartNumber],1))))) AS Rev`: This calculates the maximum value of the uppercased trimmed rightmost character of the `PartNumber` column. The result is assigned an alias `rev`.
|
|
|
|
#### 2. Data Manipulation
|
|
```sql
|
|
FROM Process
|
|
```
|
|
|
|
* The query operates on the `Process` table.
|
|
|
|
#### 3. Grouping and Sorting
|
|
```sql
|
|
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.
|