当前位置:网站首页>Usage of functions decode() and replace() in SQL

Usage of functions decode() and replace() in SQL

2022-04-23 18:35:00 Fat sb

Oracle Display the query results with other values , for example : Find out that the value of a field is abc, Can be replaced by 123 Show
grammar :
replace In general use

replace ( status , 'x' ,' male ' )
 namely : take status All occurrences in the field x Replace with male .

replace Nesting uses

replace(replace(replace(t.STATUS,'0',' normal '),'1',' Pause '),'2',' stop it ')
 namely : take status All occurrences in the field 0 Replace with normal ,1 Replace with pause ,2 Replace with stop .

decode usage

decode( Conditions , value 1, Return value 1, value 2, Return value 2,… value n, Return value n)
decode(status,'0',' normal ','1',' Pause ','2',' stop it ')
 namely : take status All occurrences in the field 0 Replace with normal ,1 Replace with pause ,2 Replace with stop .

版权声明
本文为[Fat sb]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231834007037.html