Write SQL commonly used operation records

select (case 
         when length(t.description)>20 then substr(t.description,0,20)|| '...'
         when length(t.description)<20 then t.description
       end) a,
       TO_CHAR(TRUNC(t.amount,2),'FM999,999,999,999,990.00') b,
       (substr(t.number,0,10) || chr(10) || substr(t.number,11,length(t.number))) c
  from table t

Explanation:

1、(case 
         when length(t.description)>20 then substr(t.description,0,20)|| '...'
         when length(t.description)<20 then t.description
       end) a,

       This SQL can limit the number of displayed characters, and the excess is displayed as'...'.

2、TO_CHAR(TRUNC(t.amount,2),'FM999,999,999,999,990.00') b

      Format the amount

3、(substr(t.number,0,10) || chr(10) || substr(t.number,11,length(t.number))) c

     Wrap the longer code

 

Guess you like

Origin blog.csdn.net/qq_39331713/article/details/102727546