2012-09-11 87 views
1

我的表位於oracle蟾蜍中。表中包含列名電話號碼varchar2 datatype.it包含一組電話號碼。有些數字超過10個字符。我想從右側10個字符過濾該數字。從右側獲取字符串10 char

data's in the table 
------------------- 
phone number 

9948184759 
9948220955 
994823298612 
9948249815 
99482599971234 
9948277935 
9948288258 
99483015076789 
9948335085 
9948337552 
9948338134 

the above column values are phone numbers.but some numbers are more than 10 char length 

that numbers are 
---------------- 
994823298612 
99482599971234 
99483015076789 

expected output for the above numbers 
---------------------------------------- 
4823298612 
2599971234 
3015076789 

Help me to do this? am new to oracle toad 

回答

0

可以實現通過使用SUBSTR功能例如

with T1 as 
( 
    select 99482599971234 n from dual union all 
    select 99483015076789 n from dual union all 
    select 994823298612 n from dual 
) 

select substr(n, Length(n) - 9, 10) nn 
    from t1 


Nn 
------------------- 
4823298612 
2599971234 
3015076789 
+0

我想在aspx.vb頁 – vps

+0

我的代碼中的aspx直接使用此命令。 vb從reports.renewal_contact_t中選擇PHONE,其中run_date = to_date('「+ TextBox1.Text +」',mm/dd/yyyy')和EXP_DATE = to_date('「+ TextBox2.Text +」','mm/dd/yyyy')和region ='TNP'「,cn) – vps

+0

here本身我想從右側檢索電話號碼只有10位數字 – vps

2

簡單:

select substr(phone_number, -10) from ... 
+0

@Jeffery得到像這個函數沒有足夠參數的錯誤 – vps

+0

對我來說工作正常在Oracle 10g中進行了測試。顯示確切的查詢。 –

+0

@jeffery從dual中選擇substr(123456789012 -10)。在forad for oracle中運行此查詢 – vps