【问题标题】:How to get first line of a string in oracle query?如何在 oracle 查询中获取字符串的第一行?
【发布时间】:2019-06-06 10:24:59
【问题描述】:

到期日:

15/05/12-15/07/12

minimum 15 May 2012 maximum 15 July 2012, the exact period in Charterers option

上面是列中的单元格值,我需要显示该值的唯一第一行,即 15/05/12-15/07/12

To_Char(b.Charter_End_Date, 'DD/MM/RR') || Period_Notice "Expiry Date",

预期结果:

15/05/12-15/07/12

实际结果:

15/05/12-15/07/12

minimum 15 May 2012 maximum 15 July 2012, the exact period in Charterers option

【问题讨论】:

标签: oracle


【解决方案1】:

子字符串,最多 CHR(10),可能是您要查找的内容:

SQL> select * From test;

COL
--------------------------------------------------------------------------------
15/05/12-15/07/12

minimum 15 May 2012 maximum 15 July 2012, the exact period in Charterers option


SQL> select substr(col, 1, instr(col, chr(10))) result
  2  from test;

RESULT
--------------------------------------------------------------------------------
15/05/12-15/07/12

SQL>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-24
    • 2019-07-16
    相关资源
    最近更新 更多