59 lines
2.0 KiB
Markdown
59 lines
2.0 KiB
Markdown
# MachinesWithUsage
|
|
Analysis generated on: 4/2/2025 10:02:32 AM
|
|
---
|
|
## SQL Statement
|
|
```sql
|
|
SELECT [Process by List].USAGE, [Process by List].PartName, Machines_Crosstab.*
|
|
FROM Machines_Crosstab RIGHT JOIN [Process by List] ON Machines_Crosstab.PartNumber = [Process by List].PN
|
|
ORDER BY [Process by List].USAGE DESC;
|
|
|
|
```
|
|
## Dependencies
|
|
- [[Queries/Machines_Crosstab]]
|
|
## Parameters
|
|
- *None*
|
|
## What it does
|
|
**SQL Query Description**
|
|
=========================
|
|
|
|
### Overview
|
|
|
|
This SQL query retrieves data from two tables: `Machines_Crosstab` and `[Process by List]`. It performs a right outer join on these tables based on the `PartNumber` column, which is common to both tables. The resulting data is then ordered in descending order based on the `USAGE` column of the `[Process by List]` table.
|
|
|
|
### Breakdown
|
|
|
|
#### Query Structure
|
|
```sql
|
|
SELECT
|
|
[Process by List].USAGE,
|
|
[Process by List].PartName,
|
|
Machines_Crosstab.*
|
|
FROM
|
|
Machines_Crosstab
|
|
RIGHT JOIN
|
|
[Process by List]
|
|
ON
|
|
Machines_Crosstab.PartNumber = [Process by List].PN
|
|
ORDER BY
|
|
[Process by List].USAGE DESC;
|
|
```
|
|
#### Join Type
|
|
|
|
The `RIGHT JOIN` clause is used to join the two tables. In a right outer join, all rows from both tables are returned, with NULL values in the columns of one table where there are no matches.
|
|
|
|
#### Table Columns
|
|
|
|
* `[Process by List]`: The table containing process data.
|
|
+ `.USAGE`: The column containing usage data for each process.
|
|
+ `.PartName`: The column containing part names associated with each process.
|
|
* `Machines_Crosstab`: The table containing machine data.
|
|
+ `.*`: All columns of the `Machines_Crosstab` table are included in the query results.
|
|
|
|
#### Join Condition
|
|
|
|
The join is performed on the `PartNumber` column, which is common to both tables. This ensures that only rows with matching part numbers from both tables are included in the results.
|
|
|
|
#### Ordering
|
|
|
|
Finally, the query is ordered by the `USAGE` column of the `[Process by List]` table in descending order (highest usage first).
|