Sql 如何转换Oracle数字,如0,26中的26
我试着 其中,smth是一个数字<1,如,26。我需要使用哪个SQL函数将,26转换为0,26 smth可以是、26或2345、34或2323345。我需要0,26,2345,34和2323,34 救命啊Sql 如何转换Oracle数字,如0,26中的26,sql,oracle,Sql,Oracle,我试着 其中,smth是一个数字
select smth from tableuno
如果数字为正数,则此select语句将填充前导空白。因此,如果您不想这样做,请使用的fm
修饰符to_char
:
select to_char(smth, '0.00') from tableuno;
对于大于1的值(如2314234249877),可以使用带前导9的go:to_char(smth,'99999999 0.00')
最后,正如Alex Poole指出的,有
D
来保留小数分隔符:to_char(smth,'9999999 0d00')
从dual中选择to_char(smth,'0.99')可能使用D
而不是句点,来将会话小数分隔符保留为逗号?是的,我使用了-select to_char(smth,'99999999 0.00')。谢谢!@Andrey Kargashinskiy:正如Alex提到的,您可能应该使用D作为逗号:to_char(smth,'FM99999999D00')
。
select to_char(smth, 'fm0.00') from tableuno;