Icon View Incident Report

Serious Serious
Reported By: Graeme Cox
Reported On: 10/30/2008
For: Version 2.02 Build 1
# 2834 Columns Incorrectly Allowed with Aggregate Functions in Expressions in SQL Statements

The following two lines from above query do not produce correct results:

(p.StockOnHand) * SUM(sd.SaleQuantity) AS test2,
SUM(sd.SaleAmount) / StockOnHand AS test3

* and / do not work across table fields...they result in 0
if you put in a + or - then only one of the fields is used.This is also incorrect.

SELECT
p.ProductCode,
p.ProductCode,
p.Barcode,
p.RetailPrice,
p.LastBuyPrice,
p.StockOnHand, 
SUM(sd.SaleQuantity) AS units,
SUM(sd.SaleAmount) AS cogs,
SUM(sd.SaleQuantity) * SUM(sd.SaleAmount) AS test,
SUM(sd.SaleQuantity) / SUM(sd.SaleAmount) AS test1,
(p.StockOnHand) * SUM(sd.SaleQuantity) AS test2,
SUM(sd.SaleAmount) / StockOnHand AS test3
FROM Product p
INNER JOIN SaleDetail sd ON p.ProductCode = sd.ProductCode
GROUP BY p.ProductCode
ORDER BY p.ProductName



Comments Comments and Workarounds
These types of expressions should not be allowed, since they do not make any sense and violate SQL standards. Only aggregates, functions, and constants can be used together in any expression that contains an aggregate function call.


Resolution Resolution
Fixed Problem on 10/31/2008 in version 2.02 build 3


Products Affected Products Affected
ElevateDB Additional Software and Utilities
ElevateDB DAC Client-Server
ElevateDB DAC Client-Server with Source
ElevateDB DAC Standard
ElevateDB DAC Standard with Source
ElevateDB DAC Trial
ElevateDB LCL Standard with Source
ElevateDB VCL Client-Server
ElevateDB VCL Client-Server with Source
ElevateDB VCL Standard
ElevateDB VCL Standard with Source
ElevateDB VCL Trial

Image