我需要選擇一個子字符串以從表字段中獲取連續的數字。我的表是:如何在ORACLE中選擇SUBSTRING
ORDER_NUM ORDER_DATE ORDER_TYPE LOCATION SALE_TYPE
10501702315618 08/01/17 43223 1050 18
105017023186230 21/01/17 43221 1050 230
領域ORDER_NUM如下
[LOCATION] + [YY] + [CONSECUTIVE_NUMBER] + [SALE_TYPE]
領域的位置和SALE_TYPE的長度可以different.So產生,我的查詢是:
SELECT
SUBSTR(ORDER_NUM,LENGTH (ORDER_TYPE) + 3,LENGTH (ORDER_NUM) - LENGTH (SALE_TYPE)),
ORDER_DATE
FROM
CAT_ORDERS
WHERE
LOCATION = '1050'
AND SALE_TYPE = '18'
結果是
SELECT SUBSTR('10501702315618',7,12) from dual
RESULT: 02315618
當索引位置是:
123456789
10501702315618
我怎樣才能從字符串刪除SALE_TYPE人物?還有另一個功能呢?
謝謝!
是CONSECUTIVE_NUMBER長度固定的或變化? –