[Figure: Example of a common error when grouping multiple joined tables]
The MAX function or MIN function can be used to correct the previous error, as in the following example:
Example 3:
In this example, the error in Example 2 is corrected.
Because the value of STOCKQTY is the same in each group, both the maximum and minimum values for each group
can only be one value, the STOCKQTY value. Therefore, the result of this query specification is the same as in
Figure: Example of grouping multiple tables that are joined and manipulating data. However, to improve the
processing efficiency, the SQL statement should be specified as in Example 1.
6.1.4 Recalculating calculation results for a grouped table
To recalculate results that have already been calculated for a grouped table, use a derived table. When a derived table
is used, the results can be recalculated without a view table definition. The following is a specification example:
Example:
Use the derived table used to get the total stock quantity for each product from the stock table, and get
the sums for the number of products and stock quantity.
84