3.0 KiB
3.0 KiB
Processes by material 2
Analysis generated on: 4/2/2025 10:06:04 AM
SQL Statement
SELECT [Processes by material].prt, Max([Processes by material].Rev) AS Rev, Max([Processes by material].PartNumber) AS PN INTO [Process by material]
FROM [Processes by material]
GROUP BY [Processes by material].prt
ORDER BY [Processes by material].prt, Max([Processes by material].Rev) DESC;
Dependencies
- None
Parameters
- [Forms]![Material Upgrade]![txtMaterial] (Empty)
What it does
SQL Query: Extracting Process Information by Material
Overview
This SQL query extracts and aggregates process information from a table named [Processes by material]
. It calculates the maximum revision number (Max([Processes by material].Rev)
) and part number (Max([Processes by material].PartNumber)
) for each unique process identifier ([Processes by material].prt
).
Query Breakdown
1. SELECT
Clause
SELECT [Processes by material].prt, Max([Processes by material].Rev) AS Rev,
Max([Processes by material].PartNumber) AS PN
- Selects the following columns:
[Processes by material].prt
: The process identifier.Max([Processes by material].Rev) AS Rev
: The maximum revision number for each process. The aliasRev
is used to give it a meaningful name in the output.Max([Processes by material].PartNumber) AS PN
: The maximum part number for each process. The aliasPN
is used to give it a meaningful name in the output.
2. FROM
Clause
FROM [Processes by material]
- Specifies the table from which to extract data:
[Processes by material]
.
3. GROUP BY
Clause
GROUP BY [Processes by material].prt
- Groups the extracted data by the process identifier (
[Processes by material].prt
). This means that all rows with the same value in this column will be grouped together.
4. ORDER BY
Clause
ORDER BY [Processes by material].prt, Max([Processes by material].Rev) DESC;
- Orders the grouped data first by the process identifier (
[Processes by material].prt
) and then by the maximum revision number in descending order (Max([Processes by material].Rev)
). This ensures that processes with higher revision numbers appear before those with lower revision numbers, while still maintaining their original ordering based on the process identifier.
5. INTO
Clause
INTO [Process by material]
- Specifies a destination table where the processed data will be stored:
[Process by material]
.
Result
The resulting table [Process by material]
contains the following columns:
Column Name | Data Type |
---|---|
prt |
string |
Rev |
integer |
PN |
integer |
Where:
prt
: The process identifier.Rev
: The maximum revision number for each process.PN
: The maximum part number for each process.
This query helps identify the most up-to-date process information, including the highest revision and part numbers, for each unique process identifier.