PSLine2000Documentation/Queries/Query15.md

2.0 KiB

Query15

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

SQL Statement

SELECT MercoParts.WC4, MercoParts.Machine, Sum(Format([RunStd],"0.0000")) AS Std, Sum((([LastmonthQty]/12)/22)*[runstd]) AS MonthExtHrs
FROM MercoParts
GROUP BY MercoParts.WC4, MercoParts.Machine;

Dependencies

Parameters

  • None

What it does

SQL Query Description

Overview

This SQL query retrieves data from the MercoParts table and performs calculations to determine the standard hours and extended hours worked for each machine over a period.

Breakdown

SELECT Clause


  • The query selects the following columns:
    • WC4: The primary key of the Machine table.
    • Machine: The name of the machine from the MercoParts table.
    • Std: The standard hours worked for each machine, calculated as the sum of runstd values in a standardized format ("0.0000").
    • MonthExtHrs: The extended hours worked for each machine, calculated using a formula that takes into account the monthly quantity and run standards.

Calculation Formulas


  • Std: The standard hours are calculated as the sum of runstd values in the standardized format ("0.0000").
  • MonthExtHrs: This formula calculates the extended hours worked for each machine:
    • [LastmonthQty] / 12 divides the last month's quantity by 12.
    • ( [LastmonthQty] / 12 ) / 22 further scales down the result.
    • The resulting value is then multiplied by runstd, which represents the standard hours worked in a given run.

GROUP BY Clause


  • The query groups the results by two columns:
    • WC4: The primary key of the Machine table.
    • Machine: The name of the machine from the MercoParts table.

Result

The resulting dataset will contain the standard hours and extended hours worked for each machine, grouped by machine and WC4 value. This can be useful for analyzing machine performance, identifying trends in workloads, or optimizing resource allocation.