如表中有三个字段为A、B、C,值为1、2、3,
我想把A||B||C后得到12000003,也就是说C字段需要定长为6位数,这条语句怎么写,望老师们解答,谢谢!!!

解决方案 »

  1.   

    select 1 || 2 || lpad(3,6,'0') from dual
    --把1,2,3换成你的字段名,把dual换成你的表名1||2||LPAD(3,6,'0') 
    ------------------- 
    12000003 
      

  2.   

    select to_char(a) || to_char(b) || right('00000' + to_char(c),6) from tb
      

  3.   

    --左、右边补0
    select lpad('1',5,0),rpad('1',5,0) from dual   
      

  4.   

    更改为如下:select to_char(a) || to_char(b) || reverse(substr(reverse('00000'||to_char(c)),1,6)) from tb