PSLine2000Documentation/Queries/test1 for chris brown never...

58 lines
2.8 KiB
Markdown

# test1 for chris brown never to be used again
Analysis generated on: 4/2/2025 10:12:50 AM
---
## SQL Statement
```sql
SELECT test1.PartNumber, Process.PartName, Process.PressBrake, InStr([PartName],"CONTROL") AS Expr1, InStr([PartName],"PANEL") AS Expr2
FROM test1 LEFT JOIN Process ON test1.PartNumber = Process.PartNumber
WHERE (((InStr([PartName],"CONTROL"))<>0) AND ((InStr([PartName],"PANEL"))<>0));
```
## Dependencies
- [[Tables/test1]]
- [[Tables/Process]]
## Parameters
- *None*
## What it does
**SQL Query Explanation**
==========================
### Overview
This SQL query retrieves specific data from two tables, `test1` and `Process`, based on the presence of certain strings in the `PartName` column.
### Table Descriptions
* **test1**: A table containing information about parts, with columns:
* `PartNumber`: The unique identifier for each part.
* `PartName`: The name of each part.
* **Process**: A table related to the process of manufacturing or inspecting these parts, with columns:
* `PartNumber`: The same as in the `test1` table, linking it to the corresponding part.
* `PartName`: The same as in the `test1` table, used for joining purposes.
### Query Logic
The query consists of three main components:
1. **Joining Tables**: It performs a LEFT JOIN between the `test1` and `Process` tables based on the matching `PartNumber`. This allows the query to access data from both tables.
2. **String Inquiries**: It uses the `InStr` function to check if specific strings are present in the `PartName` column of both tables:
* `(InStr([PartName],"CONTROL")\u003c\u003e0)`: Checks for the presence of the string "CONTROL" within the part name.
* `(InStr([PartName],"PANEL")\u003c\u003e0)`: Checks for the presence of the string "PANEL" within the part name.
3. **Filtering Results**: The query applies two conditions to filter the results:
* Only rows where both strings ("CONTROL" and "PANEL") are present in the `PartName` column are included.
### Query Output
The final output of this SQL query will be a set of rows containing:
* `PartNumber`: From the `test1` table.
* `PartName`: From the `Process` table, with the joined data from both tables.
* `PressBrake`: From the `Process` table (not part of the original query logic but included in the output due to the join).
* Two additional columns:
* `Expr1`: The position of "CONTROL" within the part name. If "CONTROL" is not present, it will be represented as 0.
* `Expr2`: The position of "PANEL" within the part name. If "PANEL" is not present, it will be represented as 0.
### Usage Scenario
This query might be used in a manufacturing or quality control environment to identify parts that have undergone specific processes (e.g., press brake operations) and contain certain keywords ("CONTROL" and/or "PANEL").