PSLine2000Documentation/Queries/Util Make Select 0b.md

2.6 KiB

Util Make Select 0b

Analysis generated on: 4/2/2025 10:14:14 AM

SQL Statement

SELECT "x X X" AS BestSheetSet, [Filtered Parts 3].PN, Process1.* INTO [Util Selection 0b]
FROM Process1 RIGHT JOIN ([Filtered Parts 3] LEFT JOIN Process ON [Filtered Parts 3].PN = Process.PartNumber) ON Process1.PartNumber = [Filtered Parts 3].PN
WHERE (((Process.PartNumber) Is Null) AND ((Process1.PartNumber)=[pn]))
ORDER BY Process.PartNumber;

Dependencies

Parameters

  • None

What it does

SQL Query Description

Overview

This SQL query performs a complex join operation to retrieve filtered data from multiple tables. The goal is to identify the best sheet set based on certain conditions.

Table Involved

The following tables are involved in this query:

  • Process1: A table containing process-related data with columns PartNumber and other unspecified fields (*).
  • [Filtered Parts 3]: A table containing filtered parts data with a column PN.
  • Process: Another table containing process data with a column PartNumber.

Query Steps

  1. Join Operation: The query first performs an inner join between the Process1 and [Filtered Parts 3] tables based on the PN column, resulting in a new temporary table.
  2. Left Join with Process Table: Then, it performs another left join between the temporary table from step 1 and the Process table. The join condition is that the PN column from both tables must match.
  3. Filtering and Sorting: After joining the tables, the query filters out rows where either the PartNumber in Process or Process1 is null. It also adds a filter to select only rows where [pn] equals the PartNumber in Process1.
  4. Grouping and Aggregation: The query groups the remaining rows by the PartNumber column from both tables.
  5. Output: Finally, it selects specific columns (BestSheetSet, PN) from the filtered and grouped data and assigns a default value "x X X" to the BestSheetSet column.

Output

The query produces a new table named [Util Selection 0b] with the following structure:

BestSheetSet PN
"x X X" filtered_PN

Note that the actual output will depend on the data in the Process1, [Filtered Parts 3], and Process tables.

Note

The use of Is Null condition in the WHERE clause is unusual. Typically, this would be written as IS NULL. However, based on your SQL code, I have followed it as-is to maintain consistency with your original query.