stromberg45
asked on
formatting float data types in queries
i have a number (float) in an sql table when displayed in my flex grid shows about 8 decimals places. wondering if its my flex grid property, ...or can i format/ convert my SQL query to format the number to now show more than two decimal places ?
SQL query=
SELECT dbo.tePremPurchaseLines.Li neNumber, dbo.tePremPurchaseLines.Ta xInclusive Total, dbo.tePremPurchaseLines.Qu antity,
dbo.tePremPurchaseLines.Ta xInclusive UnitPrice, dbo.tePremPurchaseLines.Di scount, dbo.tItems.ItemNumber,
dbo.tePremPurchaseLines.Pu rchaseID
FROM dbo.tePremPurchaseLines INNER JOIN
dbo.tItems ON dbo.tePremPurchaseLines.It emID = dbo.tItems.ItemID
WHERE (dbo.tePremPurchaseLines.P urchaseID = '35')
the offending fields are TaxInclusiveTotal & TaxInclusiveUnitPrice
thanks, peter.
SQL query=
SELECT dbo.tePremPurchaseLines.Li
dbo.tePremPurchaseLines.Ta
dbo.tePremPurchaseLines.Pu
FROM dbo.tePremPurchaseLines INNER JOIN
dbo.tItems ON dbo.tePremPurchaseLines.It
WHERE (dbo.tePremPurchaseLines.P
the offending fields are TaxInclusiveTotal & TaxInclusiveUnitPrice
thanks, peter.
ASKER
can you show me how to do this in the SQL language, i.e. put it into my query
thanks.
thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i can't change in table, it must be stored as float, because it's currency i'm dealing with.
thankyou for your help.the above solution worked very well.
thankyou for your help.the above solution worked very well.
>>i can't change in table, it must be stored as float, because it's currency i'm dealing with.<<
If you cannot change the data type to a more appropriate data type (such as money or numeric) than make sure you allow for rounding problems, such as such as 123.45 store as 123.4599999999. Otherwise it can be a real nightmare.
The only time you should be using float with currency is if you are dealing with the National Deficit and you need very large numbers, otherwise you are heading for trouble very fast. The Money data type is an 8 byte value and reaches a maximum of 922,337,203,685,477.5807.
If you cannot change the data type to a more appropriate data type (such as money or numeric) than make sure you allow for rounding problems, such as such as 123.45 store as 123.4599999999. Otherwise it can be a real nightmare.
The only time you should be using float with currency is if you are dealing with the National Deficit and you need very large numbers, otherwise you are heading for trouble very fast. The Money data type is an 8 byte value and reaches a maximum of 922,337,203,685,477.5807.
Typo, this:
such as 123.45 store as 123.4599999999
Should have read:
such as 123.45 store as 123.4499999999
such as 123.45 store as 123.4599999999
Should have read:
such as 123.45 store as 123.4499999999
1. CAST the float columns to Numeric(18, 2)
2. Change the data type of the float columns to (18, 2)