77 lines
2.7 KiB
Markdown
77 lines
2.7 KiB
Markdown
# GREGS_PARTS_QUERY
|
|
Analysis generated on: 4/2/2025 10:00:06 AM
|
|
---
|
|
## SQL Statement
|
|
```sql
|
|
SELECT GREGS_PARTS.PN, Process.FirstDim, Process.SecDim, Process.PartsPerBlank, Process.BlocksPerSheet, Process.PartsPerSheet, Process.BlanksPerBlock
|
|
FROM GREGS_PARTS LEFT JOIN Process ON GREGS_PARTS.PN = Process.PartNumber;
|
|
|
|
```
|
|
## Dependencies
|
|
- [[Tables/GREGS_PARTS]]
|
|
- [[Tables/Process]]
|
|
## Parameters
|
|
- *None*
|
|
## What it does
|
|
**SQL Query Description**
|
|
==========================
|
|
|
|
### Overview
|
|
|
|
This SQL query retrieves data from two tables, `GREGS_PARTS` and `Process`, based on a join condition. The resulting data is filtered to include only the columns specified in the `SELECT` clause.
|
|
|
|
### Breakdown
|
|
|
|
#### Table Selection
|
|
|
|
The query selects data from two tables:
|
|
|
|
* **GREGS_PARTS**: This table appears to store information about parts, including their part numbers (`PN`).
|
|
* **Process**: This table stores process-related data for each part, such as dimensions and quantities.
|
|
|
|
#### Join Condition
|
|
|
|
The query uses a `LEFT JOIN` to combine rows from both tables based on the matching value in the `PN` column. The join condition is:
|
|
|
|
```sql
|
|
GREGS_PARTS.PN = Process.PartNumber
|
|
```
|
|
|
|
This means that only parts with existing process data in the `Process` table will be included in the results.
|
|
|
|
#### Column Selection
|
|
|
|
The query selects specific columns from both tables using the following aliases:
|
|
|
|
* **PN**: Part number (common to both tables)
|
|
* **FirstDim**, **SecDim**: Process dimensions
|
|
* **PartsPerBlank**, **BlocksPerSheet**, **PartsPerSheet**, **BlanksPerBlock**: Process-related quantities
|
|
|
|
These columns are selected from the `Process` table, as they appear to be more relevant for process-related data.
|
|
|
|
#### Data Retrieval
|
|
|
|
The query retrieves all available columns from the `GREGS_PARTS` table and the specified columns from the `Process` table. The `LEFT JOIN` ensures that all parts with existing data in both tables are included in the results, even if there is no matching data in the `Process` table.
|
|
|
|
### Example Use Case
|
|
|
|
This query could be used to analyze process-related data for a set of parts across different manufacturing processes. For instance:
|
|
|
|
* A manufacturing company wants to identify which parts have process data available and compare their quantities or dimensions.
|
|
* An analyst needs to retrieve part numbers and corresponding process-related data to perform further analysis or reporting.
|
|
|
|
### SQL Code
|
|
|
|
```markdown
|
|
SELECT
|
|
GREGS_PARTS.PN,
|
|
Process.FirstDim,
|
|
Process.SecDim,
|
|
Process.PartsPerBlank,
|
|
Process.BlocksPerSheet,
|
|
Process.PartsPerSheet,
|
|
Process.BlanksPerBlock
|
|
FROM
|
|
GREGS_PARTS LEFT JOIN Process ON GREGS_PARTS.PN = Process.PartNumber;
|
|
```
|