如何在Oracle查询中获取字符串的第一行?

时间:2019-06-06 10:24:59

标签: oracle

有效期:

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

1 个答案:

答案 0 :(得分:0)

您正在寻找的子字符串(最大为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>