2.6 KiB
2.6 KiB
SP Util C1 Comparison
Analysis generated on: 4/2/2025 10:12:33 AM
SQL Statement
SELECT [SP Product Entry].Obsolete, [SP Product Entry].ProductID, [SP Product Entry].PartsPerUnit, [Util Selection C1].*, [SP Units].UnitsPerYear, [ActualWt]/[Usage] AS [AW/Unit], [GrossWt]/[Usage] AS [GW/Unit], [AW/Unit]*[Usage] AS [AW/Year], [GW/Unit]*[Usage] AS [GW/Year]
FROM ([SP Product Entry] LEFT JOIN [SP Units] ON [SP Product Entry].ProductID = [SP Units].ProductID) INNER JOIN [Util Selection C1] ON [SP Product Entry].PartNumber = [Util Selection C1].PartNumber
WHERE ((([SP Product Entry].Obsolete)=0))
ORDER BY [SP Product Entry].ProductID, [Util Selection C1].PartNumber;
Dependencies
- None
Parameters
- None
What it does
SQL Query Description
Overview
This SQL query retrieves data from three tables: SP Product Entry
, SP Units
, and Util Selection C1
. It joins these tables based on common columns and applies filters to the results.
Query Steps
- Left Join: The query performs a left join between
SP Product Entry
andSP Units
tables using theProductID
column as the joining criterion. This ensures that all records fromSP Product Entry
are included in the result, even if there is no matching record inSP Units
. - Inner Join: The query then joins the resulting table with
Util Selection C1
table on thePartNumber
column. - Filtering: Only records from
SP Product Entry
whereObsolete
is 0 are included in the result set, effectively excluding any obsolete products. - Aggregation: The query calculates several aggregate values:
[AW/Unit]
: Average weight per unit (calculated as[ActualWt]/[Usage]
)[GW/Unit]
: Gross weight per unit (calculated as[GrossWt]/[Usage]
)[AW/Year]
: Total average weight per year (calculated as[AW/Unit]*[Usage]
)[GW/Year]
: Total gross weight per year (calculated as[GW/Unit]*[Usage]
)
- Sorting: The results are sorted by
ProductID
and then byPartNumber
.
Returned Columns
The query returns the following columns:
[SP Product Entry].Obsolete
[SP Product Entry].ProductID
[SP Product Entry].PartsPerUnit
- Columns from
Util Selection C1
table (all) [SP Units].UnitsPerYear
[AW/Unit]
[GW/Unit]
[AW/Year]
[GW/Year]
Notes
The query uses several aliases for clarity:
[SP Product Entry]
: Table name[Util Selection C1]
: Table name[SP Units]
: Table name[ActualWt]
,[Usage]
,[GrossWt]
: Column names[AW/Unit]
,[GW/Unit]
,[AW/Year]
,[GW/Year]
: Calculated column names
These aliases make the query easier to read and understand.