ID: Q124401
The information in this article applies to:
When 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
The 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.
If 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.
This behavior is by design.
Additional reference words: FoxWin FoxDos FoxMac FoxUnix 2.50 2.50a 2.50b 2.50c 2.60 2.60a KBCategory: kbprg kbprb KBSubcategory: FxprgSql
Last Reviewed: June 27, 1995