PSLine2000Documentation/Queries/CntlPanel1.md

47 lines
2.0 KiB
Markdown

# CntlPanel1
Analysis generated on: 4/2/2025 9:57:23 AM
---
## SQL Statement
```sql
SELECT InStr(LCase([PartName]),"control") AS cntl, InStr(LCase([PartName]),"panel") AS panl, Left([partnumber],7) AS Expr1, UCase(Mid$([PartNumber],8)) AS Expr2
FROM Process
WHERE (((InStr(LCase([PartName]),"control"))<>0)) OR (((InStr(LCase([PartName]),"panel"))<>0))
ORDER BY Left([partnumber],7), UCase(Mid$([PartNumber],8)) DESC;
```
## Dependencies
- [[Tables/Process]]
## Parameters
- *None*
## What it does
**SQL Query Description**
==========================
This SQL query retrieves data from a table named `Process` and performs several string manipulation operations on the `PartName` column.
### Query Overview
The query selects specific columns from the `Process` table, filters rows based on the presence of certain substrings in the `PartName` column, and sorts the resulting data by multiple conditions.
### Selected Columns
* **cntl**: The position of the first occurrence of `"control"` in the lowercase `PartName`. If `"control"` is not found, a NULL value will be returned.
* **panl**: The position of the first occurrence of `"panel"` in the lowercase `PartName`. If `"panel"` is not found, a NULL value will be returned.
* **Expr1**: The leftmost 7 characters of the `partnumber`.
* **Expr2**: The uppercase version of the middle 8 characters (starting from position 8) of the `PartNumber`.
### Filtering Rows
The query filters rows where either `"control"` or `"panel"` is found in the lowercase `PartName`. This means that if a part has both `"control"` and `"panel"` substrings, it will be included in the result set.
### Sorting Results
The results are sorted by:
* The leftmost 7 characters of the `partnumber` (Expr1) in ascending order.
* The uppercase version of the middle 8 characters of the `PartNumber` (Expr2) in descending order.
### Example Use Case
This query might be used to analyze or process a list of parts that are part of control systems or panels, and then further filtering based on specific part numbers.