PRB: SUM in SQL Does Not Return Number with Decimal PlacesLast reviewed: June 27, 1995Article ID: Q124401 |
The information in this article applies to:
SYMPTOMSWhen using the SUM, MIN, or MAX commands in an SQL SELECT statement with the conditional IIF command, sometimes the resulting expression will not return the correct number of decimal positions. This is a problem only when the number returned should have decimal places but does not. For example, the following command returns an integer number if the first record does not meet the true condition of the IIF statement.
SELECT SUM(IIF(ytdpurch > 20, ytdpurch, 0)) FROM customer CAUSEThe SELECT statement looks at the format of the number after reading the first record. Because the first record in this case doesn't meet the true part of the IIF condition, a zero is placed as the first number to be summed because that is the false part of the IIF condition. The format of the 0 in the conditional IIF doesn't have decimal places. Therefore the format for that field in the query will not have decimal places.
WORKAROUNDIf the false part of the IIF is given decimal places, such as 0.00, the SUM statement of the SELECT command will have the correct numerical structure.
STATUSThis behavior is by design.
|
Additional reference words: FoxWin FoxDos FoxMac FoxUnix 2.50 2.50a 2.50b
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |