2.4 KiB
2.4 KiB
MachinesTrash
Analysis generated on: 4/2/2025 10:02:25 AM
SQL Statement
SELECT DISTINCTROW Left([PartNumber],7) AS PN, Machines.PartNumber, Machines.MachineName, Machines.CycleTime, Machines.Tool, Machines.Prime
FROM Machines
WHERE (((Machines.MachineName)="C-4000" Or (Machines.MachineName)="C-5000" Or (Machines.MachineName)="C-6000" Or (Machines.MachineName)="C-7000" Or (Machines.MachineName)="C-8000" Or (Machines.MachineName)="C-9000") AND ((Machines.Prime)=-1))
ORDER BY Machines.PartNumber, Machines.MachineName;
Dependencies
Parameters
- None
What it does
SQL Code Description
This SQL query retrieves specific information from the Machines
table. It filters the data based on certain conditions and orders the results.
Query Details
SELECT Clause
SELECT DISTINCTROW Left([PartNumber],7) AS PN,
Machines.PartNumber,
Machines.MachineName,
Machines.CycleTime,
Machines.Tool,
Machines.Prime
The query selects the following columns:
PN
: The first 7 characters of thePartNumber
column, aliased asLeft([PartNumber],7)
.PartNumber
: The originalPartNumber
value.MachineName
: TheMachineName
value.CycleTime
: TheCycleTime
value.Tool
: TheTool
value.Prime
: ThePrime
value.
The DISTINCTROW
clause is used to ensure that each row returned in the result set contains a unique combination of values for the selected columns.
WHERE Clause
WHERE (((Machines.MachineName)="C-4000" Or (Machines.MachineName)="C-5000" Or (Machines.MachineName)="C-6000" Or (Machines.MachineName)="C-7000" Or (Machines.MachineName)="C-8000" Or (Machines.MachineName)="C-9000") AND ((Machines.Prime)=-1))
The query filters the data based on two conditions:
- The
MachineName
column must match one of the following values: "C-4000", "C-5000", ..., "C-9000". - The
Prime
column value must be -1.
The OR
operator is used to combine multiple machine names, and the AND
operator is used to ensure that both conditions are met.
ORDER BY Clause
ORDER BY Machines.PartNumber, Machines.MachineName;
The query orders the result set by two columns:
- The original
PartNumber
value. - The
MachineName
value.
This ensures that the results are first sorted by machine number and then by machine name.