数据格式转换 x亿xxxx万xxxx,小数的 x亿xxxx万xxxx.xx

x亿xxxx万xxxx
case
        when LENGTH(t.cnt)>8 then CONCAT(left(t.cnt,length(t.cnt)-8),"亿",substr(right(t.cnt,8),1,4),"万",right(t.cnt,4))
        when LENGTH(t.cnt)>4 then CONCAT(left(t.cnt,length(t.cnt)-4),"万",RIGHT(t.cnt,4))
        else t.cnt        
        end convertnum

x亿xxxx万xxxx.xx
select concat(o.convertnum,o.cc) from( select case when LENGTH(t.cnt)>8 then CONCAT(left(t.cnt,length(t.cnt)-8),"亿",substr(right(t.cnt,8),1,4),"万",right(t.cnt,4)) when LENGTH(t.cnt)>4 then CONCAT(left(t.cnt,length(t.cnt)-4),"万",RIGHT(t.cnt,4)) else t.cnt end convertnum, cc from( select POSITION("."in r.num) as aa, left(r.num,POSITION("."in r.num)-1) as cnt, substr(r.num,POSITION("."in r.num)) as cc from (select "12345678900.56" as num) r )t ) o

 

posted @ 2023-03-03 10:47  qazvve  阅读(21)  评论(0编辑  收藏  举报