# MachinesTrash Analysis generated on: 4/2/2025 10:02:25 AM --- ## SQL Statement ```sql 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 - [[Tables/Machines]] ## 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 ```sql 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 the `PartNumber` column, aliased as `Left([PartNumber],7)`. * `PartNumber`: The original `PartNumber` value. * `MachineName`: The `MachineName` value. * `CycleTime`: The `CycleTime` value. * `Tool`: The `Tool` value. * `Prime`: The `Prime` 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 ```sql 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: 1. The `MachineName` column must match one of the following values: "C-4000", "C-5000", ..., "C-9000". 2. 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 ```sql ORDER BY Machines.PartNumber, Machines.MachineName; ``` The query orders the result set by two columns: 1. The original `PartNumber` value. 2. The `MachineName` value. This ensures that the results are first sorted by machine number and then by machine name.