50 lines
1.8 KiB
Markdown
50 lines
1.8 KiB
Markdown
# SP Product Entry
|
|
Analysis generated on: 4/2/2025 10:12:19 AM
|
|
---
|
|
## SQL Statement
|
|
```sql
|
|
SELECT [SP Products].ProductID, [SP none].PartNumber, [SP Products].PartsPerUnit, [SP Products].Obsolete
|
|
FROM [SP none] LEFT JOIN [SP Products] ON [SP none].PartNumber = [SP Products].PartNumber
|
|
ORDER BY [SP Products].ProductID, [SP none].PartNumber;
|
|
|
|
```
|
|
## Dependencies
|
|
- *None*
|
|
## Parameters
|
|
- *None*
|
|
## What it does
|
|
**SQL Code Description**
|
|
|
|
### Overview
|
|
|
|
This SQL code retrieves data from two tables, `SP none` and `SP Products`, and joins them based on a common column `PartNumber`. The resulting data is then sorted and returned.
|
|
|
|
### Breakdown
|
|
|
|
#### Table Selection
|
|
The code selects columns from the following tables:
|
|
|
|
* `[SP Products]`: Retrieves columns `ProductID`, `PartsPerUnit`, and `Obsolete`.
|
|
* `[SP none]`: Retrieves all rows, regardless of whether a match exists in the joined table.
|
|
* The selected data is retrieved using the following aliases:
|
|
+ `[SP Products]` for `SP Products`
|
|
+ `[SP none]` for `SP none`
|
|
|
|
#### Join Operation
|
|
The code performs a LEFT JOIN operation between the two tables based on the common column `PartNumber`. This means that:
|
|
|
|
* All rows from `[SP none]` are included in the result set, even if there is no matching row in `[SP Products]`.
|
|
* For each match found in `[SP Products]`, the corresponding columns from both tables are included in the result set.
|
|
|
|
#### Sorting
|
|
The resulting data is sorted in ascending order based on two columns:
|
|
|
|
1. `[SP Products].ProductID`
|
|
2. `[SP none].PartNumber`
|
|
|
|
This ensures that the rows with matching `PartNumber` values are grouped together, followed by rows without matches.
|
|
|
|
### Output
|
|
|
|
The final output will be a table containing all rows from `[SP none]`, along with the corresponding columns from `[SP Products]`. The data is sorted as specified above.
|