Subject Why do I get a CHAR as a SUM
Author venussoftop
Hi all

Maybe I did not do something right but my SUM() returns characters for these SMALLINT fields. This is data coming over from SQL-Pass Through I do in VFP if it matters. Plus these SMALLINT were recently added so the data contains NULLs in the present state.

SELECT CAST(SUM(COALESCE(lSaleDefault, 0)) AS INTEGER) AS nSaleDefault,
SUM(COALESCE(lReplacementDefault, 0)) AS nReplacementDefault,
SUM(COALESCE(lSampleDefault, 0)) AS nSampleDefault,
SUM(COALESCE(lTradingDefault, 0)) AS nTradingDefault
FROM MDOCFOOTERS
WHERE cDocType = 'SALE'
GROUP BY cDocType

As you will notice I had to do a CAST() to get a numeric for the first field, rest I have purposely kept as before for example purposes here.

Please advise what I needed to do.

Thanks and regards.
Bhavbhuti