55 lines
3.1 KiB
Markdown
55 lines
3.1 KiB
Markdown
# LamarsParts
|
|
Analysis generated on: 4/2/2025 10:01:31 AM
|
|
---
|
|
## SQL Statement
|
|
```sql
|
|
INSERT INTO [RMSFILES#_KBBLPWRK] ( PRCPN, PRCRV, PRCWH, PRCSY1, PRCBY1, PRCTY1 )
|
|
SELECT Left$([PartNumber],7) AS PartNo, Mid$([PartNumber],8,1) AS Rev, UniversalQ.Warehouse, itsazero([PartsPerSheet]) AS Expr3, itsazero([PartsPerBlank]) AS Expr2, itsazero([BlanksPerBlock]) AS Expr1
|
|
FROM UniversalQ
|
|
WHERE (((Mid$([PartNumber],8,1))<>"" And (Mid$([PartNumber],8,1))<>" " And (Mid$([PartNumber],8,1))<>"-"))
|
|
ORDER BY Left$([PartNumber],7);
|
|
|
|
```
|
|
## Dependencies
|
|
- [[Queries/UniversalQ]]
|
|
## Parameters
|
|
- *None*
|
|
## What it does
|
|
**SQL Code Description**
|
|
=====================================
|
|
|
|
### Overview
|
|
|
|
This SQL code inserts new records into a table named `[RMSFILES#_KBBLPWRK]` based on data retrieved from another table named `UniversalQ`. The insertion is performed by selecting specific columns and applying transformations to the data.
|
|
|
|
### Table and Column Descriptions
|
|
---------------------------------
|
|
|
|
* **[RMSFILES#_KBBLPWRK]**: This is the target table where new records will be inserted. The name suggests that it might be a database table used for storing information related to file management or inventory tracking.
|
|
* **PRCPN, PRCRV, PRCWH, PRCSY1, PRCBY1, PRCTY1**: These are the column names in the target table. They seem to represent various attributes of a part number, such as:
|
|
* `PRCPN`: Part Number
|
|
* `PRCRV`, `PRCHW`: Revision and Warehouse (possibly other attributes not explicitly listed)
|
|
* `PRCSY1`, `PRCBY1`, `PRCTY1`: Additional attributes related to parts per sheet, parts per blank, and blocks
|
|
|
|
### Data Selection and Transformation
|
|
--------------------------------------
|
|
|
|
* **UniversalQ**: This is the source table where data will be retrieved.
|
|
* **SELECT Statement**:
|
|
* `Left$([PartNumber],7) AS PartNo`: Extracts the first 7 characters of the `[PartNumber]` column as a new column named `PartNo`.
|
|
* `Mid$([PartNumber],8,1) AS Rev`: Extracts the character at position 8 (0-indexed) from the `[PartNumber]` column and uses it to filter out records.
|
|
* `itsazero([PartsPerSheet]) AS Expr3`, `itsazero([PartsPerBlank]) AS Expr2`, `itsazero([BlanksPerBlock]) AS Expr1`: Applies a transformation to the values in these columns using the `itsazero()` function, which likely converts numeric values to zero if they are zero.
|
|
|
|
### Filtering and Sorting
|
|
-------------------------
|
|
|
|
* **WHERE Clause**: Filters records where the character at position 8 (0-indexed) in the `[PartNumber]` column is not empty or a space.
|
|
* **ORDER BY Clause**: Sorts the resulting records based on the first 7 characters of the `[PartNumber]`.
|
|
|
|
### Additional Observations
|
|
---------------------------
|
|
|
|
* The presence of certain characters in the `[PartNumber]` column (e.g., "-", "") seems to trigger filtering in the WHERE clause. This might indicate that these characters have specific meanings or are used for formatting purposes.
|
|
|
|
Overall, this SQL code appears to be designed for importing data from `UniversalQ` into `[RMSFILES#_KBBLPWRK]`, applying transformations and filters to the data as needed, and then sorting the resulting records in a specific way.
|