PSLine2000Documentation/Queries/Query8.md

2.8 KiB

Query8

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

SQL Statement

UPDATE filter3a INNER JOIN [RMSFILES#_DANNYF] ON filter3a.Part = [RMSFILES#_DANNYF].PRDNO SET [RMSFILES#_DANNYF].NEWNET = Format([ActualWt],"#.000"), [RMSFILES#_DANNYF].NEWGRS = Format([GrossWt],"#.000");

Dependencies

  • None

Parameters

  • None

What it does

SQL Update Statement Description

Overview

This SQL update statement modifies the values in two tables: filter3a and [RMSFILES#_DANNYF]. The update is performed through a join between these two tables, which allows for filtering and manipulation of data based on matching conditions.

Breakdown

Join Clause


The statement starts with an inner join clause:

INNER JOIN [RMSFILES#_DANNYF] ON filter3a.Part = [RMSFILES#_DANNYF].PRDNO

This joins the filter3a table with the [RMSFILES#_DANNYF] table on a matching condition: Part in filter3a equals PRDNO in [RMSFILES#_DANNYF]. This allows for selecting rows from both tables that meet this condition.

Update Clause


The update clause modifies the values in the joined tables:

SET [RMSFILES#_DANNYF].NEWNET = Format([ActualWt],"#.000"), 
     [RMSFILES#_DANNYF].NEWGRS = Format([GrossWt],"#.000");

This updates two columns in the [RMSFILES#_DANNYF] table:

  1. NEWNET: sets its value to the result of formatting [ActualWt] with a comma and two zeros (e.g., 123.456 becomes 123,000).
  2. NEWGRS: sets its value to the result of formatting [GrossWt] with a comma and two zeros (e.g., 1000 becomes 1,000).

Format Function


The Format() function is used to format the values of [ActualWt] and [GrossWt]. The first argument to Format() is the value to be formatted, and the second argument is a template string that specifies the format.

In this case, the template string "#.000" means:

  • #: format as a decimal number
  • .: use a comma as the decimal separator (if specified by the locale)
  • 000: pad with zeros to three digits

By formatting [ActualWt] and [GrossWt] in this way, the resulting values are displayed with commas separating thousands, which is likely a common convention for weight or quantity measurements.

Example Use Case


This update statement might be used in a database management system where:

  • filter3a contains filter criteria for a data set
  • [RMSFILES#_DANNYF] contains additional information about the filtered items, such as weights and quantities
  • The NEWNET and NEWGRS columns need to be updated with formatted values based on the actual weight or quantity

By applying this update statement, the formatted values for NEWNET and NEWGRS can be calculated and stored in the [RMSFILES#_DANNYF] table, providing a consistent display of weights and quantities.