Hi There, I have an SQL problem I hope someone would be able to assist. I need to covert a number to string with a specific format, i.e. not ending up the number with .0000 which doesn't make sense. Is there any function in SQL Anywhere that gets a number and a format mask and produces the required string? Another one, regarding alternative to NVL function of Oracle. If I use the nullif in Strings, I still get the result as number which then get's converted. Any ideas how to prevent that? Thanks, Dvir |
AFAIK, there's no such general "number-formatting function" (though it has been requested in the past...). However, there are some general data conversion functions like STR or CAST (or conversions to numerical data with fixed number of decimal places) that may be helpful in simple cases, such as select str(6.1234), cast(6.1234567890 as varchar), cast(cast(6.1234567890 as numeric(10,2)) as varchar) returns
The following FAQ may help further: |
the convert function will take a number and convert it to text. select convert( char( 20 ), 12345.6789 ) from table will convert the number to text but will not format it to 12,345.6789 AFAIK, "convert(char, myNumber)" is semantically identical to "cast(myNumber as char)" - i.e. as long as you don't use convert() with the optional "format-style" parameter, both work similar...
(15 Feb '12, 13:40)
Volker Barth
|
COALESCE or ISNULL are SQL Anywhere's alternative to NVL, not NULLIF.