PSLine2000Documentation/Queries/Query1.md

52 lines
2.0 KiB
Markdown

# Query1
Analysis generated on: 4/2/2025 10:08:28 AM
---
## SQL Statement
```sql
SELECT DISTINCTROW Process.*, Metals.*, AddnlProc.*, Process.PartNumber
FROM (Process INNER JOIN Metals ON Process.MetalType = Metals.PartNo) INNER JOIN AddnlProc ON Process.PartNumber = AddnlProc.PartNumber
WHERE ((Process.PartNumber="9007440A"));
```
## Dependencies
- [[Queries/Metals]]
- [[Tables/AddnlProc]]
## Parameters
- *None*
## What it does
**SQL Query Description**
==========================
### Overview
This SQL query retrieves specific data from three tables: `Process`, `Metals`, and `AddnlProc`. The query joins these tables based on certain conditions and filters the results to only include rows where the `PartNumber` is "9007440A".
### Breakdown of the Query
#### SELECT Clause
The `SELECT DISTINCTROW` clause specifies that only unique rows should be returned. In this case, it selects all columns (`*`) from three tables:
* `Process`
* `Metals`
* `AddnlProc`
Additionally, it selects one column: `PartNumber`, which is common to both `Process` and `AddnlProc`.
#### FROM Clause
The query consists of two inner joins:
1. `Process INNER JOIN Metals ON Process.MetalType = Metals.PartNo`: This join combines rows from the `Process` table with those from the `Metals` table, where the `MetalType` column in `Process` matches the `PartNo` column in `Metals`.
2. `(Process INNER JOIN Metals ON Process.MetalType = Metals.PartNo) INNER JOIN AddnlProc ON Process.PartNumber = AddnlProc.PartNumber`: This join combines the result of the previous step with the `AddnlProc` table, where the `PartNumber` column in `Process` matches the `PartNumber` column in `AddnlProc`.
#### WHERE Clause
The `WHERE` clause filters the results to only include rows where:
* The `PartNumber` is equal to "9007440A".
### Query Purpose
In summary, this SQL query retrieves unique data from three tables, joining them based on specific conditions. It then filters the results to only include rows with a specific `PartNumber`.