PSLine2000Documentation/Queries/Processes by Req 1.md

60 lines
2.4 KiB
Markdown

# Processes by Req 1
Analysis generated on: 4/2/2025 10:06:58 AM
---
## SQL Statement
```sql
SELECT Left$([PN],7) AS prt, Trim$(Right$([PN],1)) AS Rev, [Process by List].PN AS PartNumber
FROM [Process by List]
ORDER BY Left$([PN],7), Trim$(Right$([PN],1)) DESC;
```
## Dependencies
- *None*
## Parameters
- *None*
## What it does
**SQL Query Description**
==========================
### Overview
This SQL query retrieves a subset of data from the `[Process by List]` table and organizes it based on a specific pattern.
### Query Breakdown
#### Select Clause
```markdown
SELECT Left$([PN],7) AS prt, Trim$(Right$([PN],1)) AS Rev, [Process by List].PN AS PartNumber
```
* The query selects three columns:
* `Left$([PN],7)` : Truncates the first 7 characters from the left side of the `[PN]` column and assigns it to a new column named `prt`.
* `Trim$(Right$([PN],1))` : Removes the last character from the right side of the `[PN]` column and assigns it to a new column named `rev`. The `$` symbol indicates that this is a string function.
* `[Process by List].PN` : Retrieves the full value of the `[PN]` column from the `[Process by List]` table.
#### From Clause
```markdown
FROM [Process by List]
```
* Specifies the table to retrieve data from, which is `[Process by List]`.
#### Order By Clause
```markdown
ORDER BY Left$([PN],7), Trim$(Right$([PN],1)) DESC;
```
* Orders the retrieved data based on two columns:
* `Left$([PN],7)` : Truncates the first 7 characters from the left side of the `[PN]` column. The order is descending.
* `Trim$(Right$([PN],1))` : Removes the last character from the right side of the `[PN]` column. The order is also descending.
### Query Behavior
* The query truncates the first 7 characters from the left side of the `[PN]` column and assigns it to the `prt` column, effectively extracting a unique identifier.
* The last character is removed from the right side of the `[PN]` column and assigned to the `rev` column. This creates a two-character code that represents the full value of the `[PN]` column minus the first 7 characters.
### Example Use Case
This query can be used in various scenarios where unique identifiers need to be extracted from a larger string, such as:
* **Data processing**: Extracting a subset of data for further processing.
* **Data filtering**: Creating a new dataset based on specific criteria.
* **Reporting and analytics**: Generating reports or summaries with distinct identifiers.