Last word in a sentence: In SQL (regular expressions possible?)

后端 未结 5 1482
夕颜
夕颜 2020-12-19 14:32

I need this to be done in Oracle SQL (10gR2). But I guess, I would rather put it plainly, any good, efficient algorithm is fine.

Given a line (or sentence, containing

5条回答
  •  粉色の甜心
    2020-12-19 14:51

    I reckon it's simpler with INSTR/SUBSTR:

    WITH q AS (SELECT 'abc def ghi' AS sentence FROM DUAL)
    SELECT SUBSTR(sentence, INSTR(sentence,' ',-1) + 1)
    FROM q;
    

提交回复
热议问题