Ask Question Forum:
Model Library:2025-02-08:A.I. model is online auto reply
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by Maliki Hassani
at 2024-11-15 06:57:21
Point:500 Replies:5 POST_ID:828793USER_ID:11697
Topic:
Oracle Database;;SQL Query Syntax
Experts,
I have a field called "Request_ID", that contains two merged Request ID's in the form of "000000001098990|000000029558106". I would like to only show all values before the "|". So show only "000000001098990". Is there a way to do this?
this works but, is this the best way because what if the amount of values increase?
SUBSTR ((AU.request_id),0,(LENGTH(AU.request_id)-16)) AS REQUEST_ID_MOD,
Current ouput:
TKT-1412155 000000001098990|000000029558106
TKT-1412155 000000001098970|000000029558106
TKT-1412155 000000001098991|000000029558106
TKT-1412155 000000001098957|000000029558106
Needing ouput:
TKT-1412155 000000001098990
TKT-1412155 000000001098970
TKT-1412155 000000001098991
TKT-1412155 000000001098957
Thanks
I have a field called "Request_ID", that contains two merged Request ID's in the form of "000000001098990|000000029558106". I would like to only show all values before the "|". So show only "000000001098990". Is there a way to do this?
this works but, is this the best way because what if the amount of values increase?
SUBSTR ((AU.request_id),0,(LENGTH(AU.request_id)-16)) AS REQUEST_ID_MOD,
Current ouput:
TKT-1412155 000000001098990|000000029558106
TKT-1412155 000000001098970|000000029558106
TKT-1412155 000000001098991|000000029558106
TKT-1412155 000000001098957|000000029558106
Needing ouput:
TKT-1412155 000000001098990
TKT-1412155 000000001098970
TKT-1412155 000000001098991
TKT-1412155 000000001098957
Thanks
Author: Maliki Hassani replied at 2024-11-18 14:42:01
Thanks!
Expert: slightwv replied at 2024-11-18 14:31:10
duncanb7,
Oracle doesn't have a SUBSTRING_INDEX function.
Oracle doesn't have a SUBSTRING_INDEX function.
Expert: duncanb7 replied at 2024-11-15 07:08:23
SELECT SUBSTRING_INDEX(Request_ID, '|', 1)
it will get the value 000000001098990
////////////////////-------SELECT SUBSTRING_INDEX(Request_ID, '|', 2)
///////////////////--------it will get the value 000000029558106
Hope it works for you
it will get the value 000000001098990
////////////////////-------SELECT SUBSTRING_INDEX(Request_ID, '|', 2)
///////////////////--------it will get the value 000000029558106
Hope it works for you
Author: Maliki Hassani replied at 2024-11-15 07:05:48
Thank you!
Accepted Solution
Expert: Steve Wales replied at 2024-11-15 07:04:16
500 points EXCELLENT
The INSTR function returns the first occurrence of a character in a string.
So, you could do something like:
select substr(col1,1,instr(col1,'|')-1)
This will take a substring of your output string, up to the character before the position of the '|'.
(Assuming that the | character that separates them is always going to be the first occurrence).
So, you could do something like:
select substr(col1,1,instr(col1,'|')-1)
This will take a substring of your output string, up to the character before the position of the '|'.
(Assuming that the | character that separates them is always going to be the first occurrence).