2.6 KiB
Filtered Parts 1
Analysis generated on: 4/2/2025 9:59:15 AM
SQL Statement
SELECT Left$([PartNumber],7) AS PartNo, UniversalQ.CutType
FROM UniversalQ
WHERE (((UniversalQ.CutType)="Multiple") AND ((Left$(Trim$([PartNumber]),1))="9") AND ((Len(Trim$([PartNumber])))>=7) AND ((UniversalQ.BotTrimCut)=2)) OR (((UniversalQ.CutType)="Multiple") AND ((Left$(Trim$([PartNumber]),1))="2")) OR (((UniversalQ.CutType)="Multiple") AND ((Left$(Trim$([PartNumber]),1))="8"))
ORDER BY Left$([PartNumber],7);
Dependencies
Parameters
- None
What it does
SQL Query Description
Overview
This SQL query retrieves specific information from the UniversalQ
table based on predefined conditions. The query filters rows where the CutType
is "Multiple", and further refines the results based on additional criteria related to the PartNumber
.
Breakdown of Conditions
The query uses a combination of logical operators (AND
, OR
) to filter rows that meet specific requirements.
Condition 1
(Left$([PartNumber],7) = "9") AND (Len(Trim$([PartNumber])) \u003e= 7)
This condition checks if the first character of the trimmed PartNumber
is "9" and the length of the trimmed PartNumber
is at least 7.
Condition 2
(Left$([PartNumber],7) = "2") OR (Len(Trim$([PartNumber])) \u003e= 7)
This condition checks if the first character of the trimmed PartNumber
is either "2" or if the length of the trimmed PartNumber
is at least 7.
Condition 3
(Left$([PartNumber],7) = "8") AND (UniversalQ.BotTrimCut = 2)
This condition checks if the first character of the trimmed PartNumber
is "8" and the value in the BotTrimCut
column is equal to 2.
Filtering Rows
The query uses an OR
statement to combine the three conditions. This means that a row will be included in the results if it meets any of the specified conditions.
Output
The query returns two columns:
PartNo
: The first 7 characters of the trimmedPartNumber
.UniversalQ.CutType
: The value from theCutType
column for each matching row.
Ordering Results
The results are ordered by the first 7 characters of the trimmed PartNumber
.
SELECT Left$([PartNumber],7) AS PartNo, UniversalQ.CutType
FROM UniversalQ
WHERE (((UniversalQ.CutType)="Multiple") AND ((Left$(Trim$([PartNumber]),1))="9") AND ((Len(Trim$([PartNumber])))\u003e=7) AND ((UniversalQ.BotTrimCut)=2))
OR (((UniversalQ.CutType)="Multiple") AND ((Left$(Trim$([PartNumber]),1))="2")) OR (((UniversalQ.CutType)="Multiple") AND ((Left$(Trim$([PartNumber]),1))="8"))
ORDER BY Left$([PartNumber],7);