68 lines
2.5 KiB
Markdown
68 lines
2.5 KiB
Markdown
# MetalPrices - Ranges
|
|
Analysis generated on: 4/2/2025 10:03:58 AM
|
|
---
|
|
## SQL Statement
|
|
```sql
|
|
SELECT MetalPrices.Type, MetalPrices.Gauge, MetalPrices.Range1, MetalPrices.Range2, MetalPrices.Range3, MetalPrices.Range4
|
|
FROM MetalPrices
|
|
WHERE (((MetalPrices.Type)=[Forms]![Utilization on Multiple Sheets]![TypeofMetal]) AND ((MetalPrices.Gauge)<>"Base"))
|
|
ORDER BY MetalPrices.Type, MetalPrices.Gauge;
|
|
|
|
```
|
|
## Dependencies
|
|
- [[Tables/MetalPrices]]
|
|
## Parameters
|
|
- [Forms]![Utilization on Multiple Sheets]![TypeofMetal] (Empty)
|
|
## What it does
|
|
**SQL Query Description**
|
|
==========================
|
|
|
|
### Overview
|
|
|
|
This SQL query retrieves specific columns from the `MetalPrices` table based on conditions related to metal type and gauge. The query filters the results to only include records with a non-base gauge.
|
|
|
|
### Step-by-Step Breakdown
|
|
|
|
1. **Select Columns**: The query selects the following columns:
|
|
* `Type`
|
|
* `Gauge`
|
|
* `Range1`
|
|
* `Range2`
|
|
* `Range3`
|
|
* `Range4`
|
|
|
|
2. **Filter by Metal Type**:
|
|
The query uses a conditional statement to filter records based on the value of the `Type` column.
|
|
```sql
|
|
WHERE (((MetalPrices.Type)=[Forms]![Utilization on Multiple Sheets]![TypeofMetal]))
|
|
```
|
|
This expression essentially sets the `Type` column to the selected metal type from a dropdown list in Excel.
|
|
|
|
3. **Filter by Gauge**:
|
|
The query also filters records based on the value of the `Gauge` column.
|
|
```sql
|
|
AND ((MetalPrices.Gauge)\u003c\u003e"Base")
|
|
```
|
|
This condition ensures that only records with a gauge other than "Base" are included in the results.
|
|
|
|
4. **Sort Results**:
|
|
Finally, the query sorts the filtered results by both the `Type` and `Gauge` columns.
|
|
```sql
|
|
ORDER BY MetalPrices.Type, MetalPrices.Gauge;
|
|
```
|
|
This ordering ensures that records with the same metal type are listed in ascending order of gauge.
|
|
|
|
### Example Use Case
|
|
|
|
This query can be used to retrieve pricing information for a specific type of metal (e.g., aluminum) and gauge (e.g., 1/4") from an Excel sheet containing metal prices. The query would filter out records for base metal prices, providing only the desired data for further analysis or reporting purposes.
|
|
|
|
### SQL Query Code
|
|
|
|
```markdown
|
|
SELECT MetalPrices.Type, MetalPrices.Gauge, MetalPrices.Range1, MetalPrices.Range2,
|
|
MetalPrices.Range3, MetalPrices.Range4
|
|
FROM MetalPrices
|
|
WHERE (((MetalPrices.Type)=[Forms]![Utilization on Multiple Sheets]![TypeofMetal]) AND ((MetalPrices.Gauge)\u003c\u003e"Base"))
|
|
ORDER BY MetalPrices.Type, MetalPrices.Gauge;
|
|
```
|