I have a follow up question with regards to a similar issue I'm having, as the one posted on this thread: Why when converting SQL Real to Numeric does the scale slightly increase?.
I'm using Sybase IQ 16. I have a column called - StrikePrice with float datatype in a table called ProductTb. For a certain record, the value in the table for this column is StrikePrice=22411.39.
When I try to convert it in either decimal or numeric as follows : convert(decimal(31,5), StrikePrice) OR convert(numeric(31,5), StrikePrice), this gives a result as - 22411.39189.
How do I make sure that this shows the value as - 22411.39000 instead of 22411.39189? Is there any workaround that I can use to achieve this?
Thanks in advance for your help.
Example of what I'm looking for: When I have a value of let's say : 0.0090827, the desired output needed is : 0.00908 i.e. limited to 5 digits after the decimal. And when I have a value of : 22411.39, the desired output is : 22411.39000.
Adding more details
This(above explained issue) seems to work fine on Sybase ASE and the results are what I expect on ASE. The issue is only on Sybase IQ. See details below:
Sybase ASE (15.7):
select TradeNum, StrikePrice as "Original Strike Price in Database", convert(numeric(31, 5), StrikePrice) as "Converted Strike Price" from ProductTb where TradeNum in (8463676,72372333)
TradeNum Original Strike Price in Database Converted Strike Price
8463676 61.65 61.65000
72372333 85.6 85.60000
72372333 85.6 85.60000
Sybase IQ (16):
select TradeNum, StrikePrice as "Original Strike Price in Database", convert(numeric(31, 5), StrikePrice) as "Converted Strike Price" from ProductTb where TradeNum in (8463676,72372333)
TradeNum Original Strike Price in Database Converted Strike Price
72372333 85.6 85.59999
72372333 85.6 85.59999
8463676 61.65 61.64999