87 lines
3.1 KiB
Markdown
87 lines
3.1 KiB
Markdown
# Util Make Select 0a
|
|
Analysis generated on: 4/2/2025 10:14:03 AM
|
|
---
|
|
## SQL Statement
|
|
```sql
|
|
SELECT "x X X" AS BestSheetSet, [Filtered Parts 3].PN, Process.* INTO [Util Selection 0]
|
|
FROM [Filtered Parts 3] LEFT JOIN Process ON [Filtered Parts 3].PN = Process.PartNumber
|
|
WHERE (((Process.PartNumber)<>""))
|
|
ORDER BY Process.PartNumber, [Filtered Parts 3].PN;
|
|
|
|
```
|
|
## Dependencies
|
|
- [[Tables/Parts]]
|
|
- [[Tables/Process]]
|
|
## Parameters
|
|
- *None*
|
|
## What it does
|
|
**SQL Query Description**
|
|
=========================
|
|
|
|
### Overview
|
|
|
|
This SQL query retrieves data from two tables: `[Filtered Parts 3]` and `Process`. The query filters the results to include only valid part numbers and selects specific columns. The output is transformed into a new table named `[Util Selection 0]`.
|
|
|
|
### Step-by-Step Breakdown
|
|
|
|
#### 1. Column Aliasing
|
|
|
|
```sql
|
|
SELECT "x X X" AS BestSheetSet, [Filtered Parts 3].PN, Process.*
|
|
```
|
|
|
|
* This line selects the first row of values as a literal string `"x X X"` and assigns it to a column alias `BestSheetSet`.
|
|
* The `Processed Parts 3` table is then selected for its `PN` (Part Number) value.
|
|
* Finally, all columns from the `Process` table are selected using `Process.*`.
|
|
|
|
#### 2. Joining Tables
|
|
|
|
```sql
|
|
FROM [Filtered Parts 3] LEFT JOIN Process ON [Filtered Parts 3].PN = Process.PartNumber
|
|
```
|
|
|
|
* This line joins the `[Filtered Parts 3]` table with the `Process` table on a common column: `PartNumber`.
|
|
* The join type is set to `LEFT JOIN`, which means that all records from the left table (`[Filtered Parts 3]`) will be included in the results, even if there are no matches in the right table.
|
|
|
|
#### 3. Filtering
|
|
|
|
```sql
|
|
WHERE (((Process.PartNumber)\u003c\u003e""))
|
|
```
|
|
|
|
* This line applies a filter to exclude any rows where `Process.PartNumber` is an empty string (`\u003c\u003e ""`).
|
|
* The triple parentheses around `Process.PartNumber` ensure that only non-empty strings are included in the results.
|
|
|
|
#### 4. Sorting
|
|
|
|
```sql
|
|
ORDER BY Process.PartNumber, [Filtered Parts 3].PN;
|
|
```
|
|
|
|
* This line sorts the filtered results by two columns:
|
|
* First, by the `PartNumber` column of the `Process` table.
|
|
* Second, by the `PN` (Part Number) value from the `[Filtered Parts 3]` table.
|
|
|
|
#### 5. Output Transformation
|
|
|
|
```sql
|
|
INTO [Util Selection 0]
|
|
```
|
|
|
|
* This line creates a new output table named `[Util Selection 0]`.
|
|
* The `INTO` clause is used to specify the destination for the query's results.
|
|
|
|
**Example Use Case**
|
|
|
|
This SQL query might be used in an inventory management system to retrieve part numbers with valid data from both the `[Filtered Parts 3]` and `Process` tables. The sorted output could help with identifying parts that need attention, such as those with no matching process information or incomplete data.
|
|
|
|
**Output Format**
|
|
|
|
The final output will have the following columns:
|
|
|
|
* `BestSheetSet`: a constant string `"x X X"`
|
|
* `PN`: the part number from `[Filtered Parts 3]`
|
|
* The other columns from the `Process` table, sorted by `PartNumber` and then `PN`
|
|
|
|
Note: The exact column names and data types may vary depending on the actual schema of the tables involved.
|