PSLine2000Documentation/Queries/AddnlMKQ.md

2.4 KiB

AddnlMKQ

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

SQL Statement

SELECT DISTINCTROW AddnlProc.*
FROM AddnlProc
WHERE ((AddnlProc.Generated=No))
ORDER BY AddnlProc.PartNumber, AddnlProc.OPCode;

Dependencies

Parameters

  • None

What it does

SQL Query Description

Overview

The given SQL query retrieves a distinct subset of records from the AddnlProc table, filtering out rows where the Generated field has a value of "No", and sorting the remaining results by two specific columns.

Step-by-Step Explanation

1. Selecting Distinct Rows


  • The first line, SELECT DISTINCTROW AddnlProc.*, selects all columns (*) from the AddnlProc table.
  • The DISTINCTROW keyword ensures that each row in the result set is unique, meaning no duplicate rows will be returned.

2. Filtering by Generated Field


  • The next line, FROM AddnlProc, specifies the table to query, which is again AddnlProc.
  • The subsequent line, WHERE (AddnlProc.Generated = 'No'), filters out rows where the value of the Generated field is "No". This effectively excludes records that have not been generated.

3. Sorting Results


  • The final two lines, ORDER BY AddnlProc.PartNumber, AddnlProc.OPCode;, sort the remaining rows in ascending order based on two columns:
    • AddnlProc.PartNumber
    • AddnlProc.OPCode

Overall Behavior

This SQL query is designed to retrieve a distinct subset of records from the AddnlProc table that have not been generated, and then sort these results by part number and OP code. This can be useful in various scenarios where data needs to be processed or analyzed after filtering out non-generated records.

Example Use Case

Suppose you are working with a database that tracks additional processing for parts (e.g., "OP Code" is the code associated with the operation performed). You want to identify and process only those parts that have not been generated yet. This SQL query can help you achieve this by filtering out non-generated records and sorting the remaining results in ascending order based on part number and OP code.

Output

The output of this SQL query will be a sorted list of unique rows from the AddnlProc table where the Generated field is "No", with each row containing all columns (*) from the original table.