PSLine2000Documentation/Queries/AddnlMakeQ.md

2.2 KiB

AddnlMakeQ

Analysis generated on: 4/2/2025 9:56:14 AM

SQL Statement

SELECT DISTINCTROW Process.*, AddnlProc.ID, AddnlProc.Generated, AddnlProc.OPCode, AddnlProc.Description, AddnlProc.WC1, AddnlProc.WC2, AddnlProc.WC3, AddnlProc.WC4, AddnlProc.Machine, AddnlProc.CycleTime, AddnlProc.RunStd
FROM Process RIGHT JOIN AddnlProc ON Process.PartNumber = AddnlProc.PartNumber
WHERE ((AddnlProc.PartNumber="9001891A" Or AddnlProc.PartNumber="k2"));

Dependencies

Parameters

  • None

What it does

SQL Query Description

Overview

This SQL query retrieves data from two tables, Process and AddnlProc, based on specific conditions. The query uses a RIGHT JOIN operation to combine rows from both tables.

Table Involvement

  • Process: A table containing process-related data.
  • AddnlProc: A table containing additional process data related to each part number.

Join Operation

The query performs a RIGHT JOIN between the two tables on the PartNumber column. This means that all rows from the Process table are included in the result set, and only matching rows from the AddnlProc table are added if there is a match based on the PartNumber.

Conditions

The query applies two conditions to filter the data:

  1. The PartNumber column of either the Process or AddnlProc table must equal one of the specified values: "9001891A" or "k2".

Selected Columns

The query selects specific columns from both tables, including all columns from the Process table and selected columns from the AddnlProc table. The selected columns are:

  • ID
  • Generated
  • OPCode
  • Description
  • WC1, WC2, WC3, and WC4 (Waste Codes)
  • Machine
  • CycleTime
  • RunStd

DistinctROW Clause

The query includes the DISTINCTROW clause, which ensures that only unique combinations of columns from both tables are returned in the result set.

Purpose

This SQL query is likely used to retrieve specific process data related to a particular part number (9001891A or k2) and its corresponding additional process data. The distinct rows ensure that duplicate combinations of column values are not included in the result set.