PSLine2000Documentation/Queries/KM QRY Shreve Park Material...

48 lines
2.4 KiB
Markdown

# KM QRY Shreve Park Material Usage
Analysis generated on: 4/2/2025 10:01:13 AM
---
## SQL Statement
```sql
SELECT Process.PartNumber, Process.Warehouse, Process.Utilization, Process.ActualWt, Process.GrossWt, Metals.MetalName, Metals.Gauge, Metals.PartNo, Metals.Density, Metals.Length, Metals.Width, Metals.WarehouseLocation, Metals.Location, Metals.AltPartNo, Metals.PricePerLB, Metals.PurchaseBlank, Metals.Units
FROM Process INNER JOIN Metals ON Process.MetalType = Metals.PartNo
WHERE (((Process.Warehouse)="02"))
ORDER BY Process.PartNumber;
```
## Dependencies
- [[Tables/Process]]
- [[Queries/Metals]]
## Parameters
- *None*
## What it does
**SQL Query Description**
==========================
This SQL query retrieves data from two tables, `Process` and `Metals`, which are joined on the `MetalType` column. The query filters results to include only records where the warehouse code is "02" and sorts the output by part number.
### Table Selection
The query selects data from three columns in each table:
* **Process**: `PartNumber`, `Warehouse`, `Utilization`, `ActualWt`, `GrossWt`
* **Metals**: `MetalName`, `Gauge`, `PartNo`, `Density`, `Length`, `Width`, `WarehouseLocation`, `Location`, `AltPartNo`, `PricePerLB`, `PurchaseBlank`, `Units`
### Join and Filtering
The query joins the two tables on the `MetalType` column, which is equivalent to the `PartNo` column in the `Metals` table. The join condition ensures that each record in `Process` has a corresponding match in `Metals`.
The `WHERE` clause filters the results to include only records where:
* The warehouse code is equal to "02" (`Process.Warehouse = "02"`).
### Sorting and Retrieval
Finally, the query sorts the filtered results by the `PartNumber` column (`ORDER BY Process.PartNumber`) and retrieves all columns specified in the `SELECT` statement.
**Example Output**
------------------
The resulting dataset will include all columns selected from both tables, with sorted data for each part number where the warehouse code is "02".
| PartNumber | Warehouse | Utilization | ActualWt | GrossWt | MetalName | Gauge | PartNo | Density | Length | Width | WarehouseLocation | Location | AltPartNo | PricePerLB | PurchaseBlank | Units |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
This query is useful for analyzing production data, inventory management, or material sourcing processes where multiple warehouses and materials are involved.