Format decimal places directly in the SQL command in Firebird

10

I have a ESTOQUE table containing a field called QTDE , this field has 3 decimal places.

What would be the command to return straight from SQL formatted with 3 houses? Because the whole values are returning without the houses.

I use: Firebird 2.0 / Field: Decimal (15,3)

    
asked by anonymous 31.01.2014 / 14:04

7 answers

11

Try this:

SELECT cast(seu_campo AS NUMERIC(15,3)) FROM sua_tabela

I believe your intention is to show this on the screen so try:

select cast(seu_campo as varchar(10)) from sua_tabela
    
31.01.2014 / 14:13
3

I made select using:

CAST(CAST(a.CAMPO AS DECIMAL(18,6)) AS VARCHAR(30))

It worked perfectly.

    
04.03.2015 / 18:26
2

I set Firebird 2.0 here on my system, I created a table with QTDE field, with DECIMAL(15,3) . I entered 4 numbers, 10.521 , 11.11 , 65 , and 65.88 . After that I made SELECT * FROM tabela; , and returned with all necessary houses, including 65.000 .

Is there any configuration with the client that is using to do SQL? I used Database Workbench v4.4.3 Lite, Firebird Edition to do everything.

    
31.01.2014 / 19:46
2

Convert Varchar to decimal, before you have to convert a point by point for the command to work:

cast( replace(p.valor_venda,',','.') as decimal(18,6))

Make the above way that works ...

    
01.10.2014 / 05:05
1

select format(1.003, 'N', 'pt-br') = 1.00% select format(1.03, 'G', 'pt-br') = 1,0300% select format(1.489, 'C', 'pt-br') = $ 1.49

    
08.07.2015 / 13:35
1

Example in case of VIEW that I created:

ALTER VIEW vw_Saldos_Clientes as
Select C.ID_Cliente as ID, C.Nome_Cliente as Cliente,
format(C.Saldo, 'C', 'pt-br') as Saldo
FROM dbo.tbl_Clientes C (NoLock)

Result:

1   Rafael Vilaça       R$ 5.720,00
2   Fernanda Fabiana    R$ 2.600,00
3   Renata Mendonça     R$ 2.600,00
4   Lucas Rosa          R$ 2.600,00
5   Luis Fernando       R$ 2.600,00

The command " format(C.Saldo, 'C', 'pt-br') " formats the Money value for the currency type of Brazil (R $)

I hope I have been clear ... Thank you ...

    
26.04.2016 / 22:54
-1

Good friend I did the following way, I looked for as far as I want, then I fed the bank again with the value that I looked for.

updateoepdsetpesliq=(SELECTcast(pesliqASNUMERIC(15,3))asvalorFROMe210epdasoriwhereori.numemb=oepd.numembandori.codlot=oepd.codlot)frome210epdasoepdwherenumemb=14242

    
25.07.2018 / 16:43