当前位置: 代码迷 >> Oracle开发 >> 这个语句要如何写!SQL
  详细解决方案

这个语句要如何写!SQL

热度:39   发布时间:2016-04-24 07:44:25.0
这个语句要怎么写!SQL
select * from test_tab

 no
---------
123
12
1
123
23

要怎么写个语句实现如下格式
no
---------
123
012
001
123
023
不足3位的用零补足??????????????

------解决方案--------------------
用lpad函数。
------解决方案--------------------
no -> no1

select decode(sign(length(tt.no1) - 3), -1, lpad(tt.no1, 3, '0'), tt.no1) as no1
from test_tab tt;
  相关解决方案