I need select a subtring to get the consecutive number from a table field. My table is:
ORDER_NUM ORDER_DATE ORDER_TYPE LOCATION SALE_TYPE
10501702315618 08/01/17 43223 1050 18
105017023186230 21/01/17 43221 1050 230
The field ORDER_NUM is generated as follows
[LOCATION] + [YY] + [CONSECUTIVE_NUMBER] + [SALE_TYPE]
The length of the fields LOCATION and SALE_TYPE Can be different.So, my query is:
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'
The result is
SELECT SUBSTR('10501702315618',7,12) from dual
RESULT: 02315618
Where the index position is:
12345678901234
10501702315618
How i can delete the SALE_TYPE characters from the string? There is another function for this ?
Thank's!