gpt4 book ai didi

ORACLE:- SELECT First Names ,通过删除第一个单词后的空格

转载 作者:行者123 更新时间:2023-12-05 00:36:46 25 4
gpt4 key购买 nike

甲骨文:-
表中的名字如下

Binda  E                                                                             
Reven O
Drew J
ANDAL J
WILL Lee
Chad Hardee

我想选择以下格式的名字
Binda                                                                               
Reven
Drew
ANDAL
WILL
Chad

我正在使用以下查询,但没有运气
SELECT  first_name, SUBSTR(first_name, REGEXP_INSTR('first_name','[^ ]+', 1, 1) ) FROM contact.user_names

请建议。

最佳答案

NVL(substr(first_name, 1, instr(first_name,' ')), first_name)

with t AS
(
SELECT 'Binda E ' as first_name FROM dual
union
SELECT 'Reven O ' as first_name FROM dual
union
SELECT 'Drew J ' as first_name FROM dual
union
SELECT 'ANDAL J ' as first_name FROM dual
union
SELECT 'WILL Lee ' as first_name FROM dual
union
SELECT 'Chad Hardee' as first_name FROM dual
union
SELECT 'foobar' as first_name FROM dual

)
SELECT NVL(substr(first_name, 1, instr(first_name,' ')), first_name) FROM t
;

关于ORACLE:- SELECT First Names ,通过删除第一个单词后的空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7838218/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com