63 lines
2.2 KiB
Markdown
63 lines
2.2 KiB
Markdown
# SalvagniniQuery
|
|
Analysis generated on: 4/2/2025 10:10:35 AM
|
|
---
|
|
## SQL Statement
|
|
```sql
|
|
SELECT Machines.PartNumber, Machines.MachineName, Machines.CycleTime, Machines.Tool, Machines.Prime, Left([MachineName],1) AS Test
|
|
FROM Machines
|
|
WHERE (((Left([MachineName],1))="S" Or (Left([MachineName],1))="P"))
|
|
ORDER BY Machines.MachineName, Machines.CycleTime;
|
|
|
|
```
|
|
## Dependencies
|
|
- [[Tables/Machines]]
|
|
## Parameters
|
|
- *None*
|
|
## What it does
|
|
**SQL Query Description**
|
|
==========================
|
|
|
|
### Overview
|
|
|
|
This SQL query retrieves data from the `Machines` table based on certain conditions. It selects specific columns and applies filters to narrow down the results.
|
|
|
|
### Breakdown
|
|
|
|
#### SELECT Statement
|
|
```sql
|
|
SELECT
|
|
Machines.PartNumber,
|
|
Machines.MachineName,
|
|
Machines.CycleTime,
|
|
Machines.Tool,
|
|
Machines.Prime,
|
|
Left([MachineName],1) AS Test
|
|
```
|
|
|
|
* The query selects five columns from the `Machines` table: `PartNumber`, `MachineName`, `CycleTime`, `Tool`, and `Prime`.
|
|
* Additionally, it creates a new column named `Test` that contains the first character of the `MachineName`.
|
|
|
|
#### WHERE Clause
|
|
```sql
|
|
FROM Machines
|
|
WHERE (((Left([MachineName],1))="S" Or (Left([MachineName],1))="P"))
|
|
```
|
|
|
|
* The query filters rows based on two conditions:
|
|
* `Left([MachineName], 1) = "S"`: Returns only the rows where the first character of `MachineName` is "S".
|
|
* `Left([MachineName], 1) = "P"`: Returns only the rows where the first character of `MachineName` is "P".
|
|
* The two conditions are combined using the `OR` operator, allowing rows that meet either condition to be included in the results.
|
|
|
|
#### ORDER BY Clause
|
|
```sql
|
|
ORDER BY Machines.MachineName, Machines.CycleTime;
|
|
```
|
|
|
|
* Finally, the query sorts the filtered results by:
|
|
* The `MachineName`: Rows are sorted alphabetically by the `MachineName` column.
|
|
* The `CycleTime`: Within each group of rows with matching `MachineName`, rows are sorted in ascending order by the `CycleTime` column.
|
|
|
|
### Example Use Case
|
|
|
|
This query can be used to retrieve a list of machines that start with "S" or "P", along with their respective part numbers, names, cycle times, and other attributes. The results can then be further processed or analyzed based on these conditions.
|