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

发布于 2024-12-11 04:35:11 字数 1030 浏览 0 评论 0原文

甲骨文:- 在表中,名字如下

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

请建议。

ORACLE:-
In the table the First Names are as follows

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

I want to select First names in the following format

Binda                                                                               
Reven                                                                                  
Drew                                               
ANDAL                                                                                         
WILL                                              
Chad   

I am using the following Query, but a having no luck

SELECT  first_name, SUBSTR(first_name, REGEXP_INSTR('first_name','[^ ]+', 1, 1) ) FROM contact.user_names

Kindly suggest.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

过期以后 2024-12-18 04:35:11

NVL(substr(名字, 1, instr(名字,' ')), 名字)

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
    ;

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
    ;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文