[英]How to get a result with three characters
I need to get a value of column with three characters instead of one. 我需要使用三个字符而不是一个字符来获取column的值。
this is my request : select rank() over (order by 1,2,32 ) from dual
这是我的要求: select rank() over (order by 1,2,32 ) from dual
and these is the result : 结果是:
I need to get 001
instead of 1
我需要得到001
而不是1
Thanks for your help 谢谢你的帮助
可能是最简单的解决方案:
select to_char(rank() over (order by 1,2,32 ),'fm000') from dual
IMO, You can use SUBSTR()
like this: IMO,您可以像这样使用SUBSTR()
:
SELECT SUBSTR('000' || CAST((RANK() OVER (ORDER BY 1,2,32)) AS VARCHAR(3)), -3, 3)
FROM DUAL;
Not tested yet ;). 尚未测试;)。
select lpad(rank() over (order by 1,2,32 ),3,0) from dual;
select substr('00' || rank() over (order by 1,2,32 ),1,3) from dual;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.