PSLine2000Documentation/Queries/Q3.md

54 lines
1.3 KiB
Markdown

# Q3
Analysis generated on: 4/2/2025 10:08:09 AM
---
## SQL Statement
```sql
SELECT DISTINCTROW Process.*
FROM Process
ORDER BY Mid$([PartNumber],4);
```
## Dependencies
- [[Tables/Process]]
## Parameters
- *None*
## What it does
**SQL Query Description**
==========================
### Overview
The provided SQL query retrieves distinct rows from the `Process` table, ordered by a specific column.
### Breakdown
#### SELECT Clause
```sql
SELECT DISTINCTROW Process.*
```
* The `SELECT DISTINCTROW` clause specifies that only unique rows should be returned.
* The `Process.*` syntax selects all columns (`*`) from the `Process` table.
#### FROM Clause
```sql
FROM Process
```
* This clause specifies the table to retrieve data from, which is the `Process` table.
#### ORDER BY Clause
```sql
ORDER BY Mid$([PartNumber],4);
```
* The `ORDER BY` clause sorts the retrieved rows in ascending order based on a specified column.
* The `Mid$` function extracts a specific substring from the `PartNumber` column:
* `$(` denotes the start of an expression enclosed within parentheses.
* `Mid$` is likely an alias for the `SUBSTRING` or `LEFT`/`RIGHT` functions in SQL Server.
* The first argument to `Mid$` is `PartNumber`, and the second argument is `4`.
* The `4` means that 4 positions from the beginning of the string are extracted.