PSLine2000Documentation/Queries/K_NUM_1.md

43 lines
1.7 KiB
Markdown

# K_NUM_1
Analysis generated on: 4/2/2025 10:00:22 AM
---
## SQL Statement
```sql
SELECT DISTINCTROW AddnlQ1.PartNumber, AddnlQ1.OPCode, AddnlQ1.Machine, AddnlQ1.RunStd
FROM AddnlQ1
WHERE (((Left$(UCase$([PartNumber]),1))="K"));
```
## Dependencies
- [[Queries/AddnlQ1]]
## Parameters
- *None*
## What it does
**SQL Query Description**
==========================
This SQL query retrieves distinct rows from the `AddnlQ1` table based on a specific condition.
### Overview
The query selects unique values for three columns: `PartNumber`, `OPCode`, and `Machine`. The selection is constrained by a regular expression pattern applied to the `PartNumber` column.
### Query Breakdown
1. **SELECT DISTINCTROW**: This clause specifies that only distinct rows should be returned in the result set.
2. **AddnlQ1.PartNumber, AddnlQ1.OPCode, AddnlQ1.Machine**: These columns are selected for retrieval from the `AddnlQ1` table.
3. **FROM AddnlQ1**: The query selects data from the `AddnlQ1` table.
4. **WHERE (((Left$(UCase$([PartNumber]),1))="K"))**:
* This clause applies a conditional filter to the data.
* `Left$(...)`: Extracts the first character from the string using the `Left` function.
* `UCase$(...)`: Converts the string to uppercase using the `UCase` function.
* `[PartNumber]`: Specifies that the expression should be applied to the `PartNumber` column.
### Condition
The condition `((Left$(UCase$([PartNumber]),1))="K")` checks if the first character of the uppercase `PartNumber` is equal to 'K'. If this condition is true, the row is included in the result set.
### Result
The query returns a distinct subset of rows from the `AddnlQ1` table where the `PartNumber` starts with the letter 'K', and includes unique values for `OPCode`, `Machine`, and `RunStd`.