oracle怎么去除0,oracle怎么去除空格

oracle去掉數(shù)字后面的0

給你做個(gè)試驗(yàn)?zāi)憔椭懒?/p>

成都創(chuàng)新互聯(lián)主要從事做網(wǎng)站、網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)沂水,十多年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):18982081108

create?table?test

(id?varchar2(6));

insert?into?test?values?('120000');

insert?into?test?values?('120010');

insert?into?test?values?('120200');

insert?into?test?values?('123000');

insert?into?test?values?('123001');

commit;

執(zhí)行第一遍:

update?test?set?id=substr(id,1,5)?where?id?like?'%0';

commit;

此時(shí)結(jié)果:

執(zhí)行第二遍:

update?test?set?id=substr(id,1,4)?where?id?like?'%0';

commit;

后邊就不舉例了,也就是語句執(zhí)行4遍,需要修改里邊的參數(shù)。

oracle數(shù)據(jù)庫如何分段去0

我寫一份,你試試,看看能不能通過一個(gè)SQL就能完成

select t.employee_id employee_id,

t.department_id department_id,

min(t.start_date) date,

min(t.start_date) start_date,

max(t.end_date) end_date,

(select t2.position

from table_name t2

where t2.employee_id = employee_id

and t2.department_id=department_id

and t2.end_date =end_date ) position

from table_name t

group by employee_id,

department_id,

position

oracle如何獲取當(dāng)前月份,去掉前面的0

如果字符串只有開頭有零,而字符串中間沒有0,那么可以使用replace(字符串,'0','')

如果0開頭最長的位數(shù)不長,那么可以逐個(gè)判斷。

比如我可能知道這里面最長的就是連續(xù)5個(gè)0開頭的,這樣我就判斷如果遇到5個(gè)0開頭的就截掉前五位,4個(gè)0開頭截掉前四位,3個(gè)0開頭截掉前三位,一直到1,逐個(gè)判斷使用case when可以完成.但是如果最長的0開頭個(gè)數(shù)不確定,就比較麻煩了。

當(dāng)前名稱:oracle怎么去除0,oracle怎么去除空格
網(wǎng)頁路徑:http://muchs.cn/article44/hciiee.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App開發(fā)、品牌網(wǎng)站設(shè)計(jì)、網(wǎng)站收錄網(wǎng)站改版、建站公司、服務(wù)器托管

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

搜索引擎優(yōu)化