Subject RE: [firebird-support] zeros of a field decimal
Author Svein Erling Tysvær
I've at least never heard of such a function, and generally think that how things are displayed is something for client programs to decide rather than a database server. Though, it is of course possible, at least for display purposes, to fake such an algorithm. Assuming the number is a fixed decimal (floating point decimals are something completely different) with a value less than 10:

SELECT
CASE WHEN MyValue = cast(MyValue as Integer) then cast(MyValue as CHAR(1))
WHEN MyValue = cast(MyValue*10 as Integer)/10.0 then cast(MyValue as CHAR(3))
WHEN MyValue = cast(MyValue*100 as Integer)/100.00 then cast(MyValue as CHAR(4))
WHEN MyValue = cast(MyValue*1000 as Integer)/1000.000 then cast(MyValue as CHAR(5))
WHEN MyValue = cast(MyValue*10000 as Integer)/10000.0000 then cast(MyValue as CHAR(6))
END
...

I haven't tried this, if Firebird complains, then add a few spaces (||' ', ||' ', ||' ', ||' ' respectively) to the result so that they're all equally long.

HTH,
Set

-----Original Message-----
From: firebird-support@yahoogroups.com [mailto:firebird-support@yahoogroups.com] On Behalf Of Ismael L. Donis García
Sent: 25. mai 2009 18:28
To: firebird-support@yahoogroups.com
Subject: [firebird-support] zeros of a field decimal

Exists any function that returns the value without zeros of a field decimal.

Example:

select function(a.cantidad) as cantidad from tabla a

Value Result

3.0000 3

3.0100 3.01

3.0210 3.021

3.0004 3.0004

Thanks and Excuse the simplicity of the question but I do not find anything than accomplish such operation.
=========
¦¦ ISMAEL ¦¦
=========