如何剪切此SQL查询结果并使用我的其他查询?

时间:2017-12-20 20:54:16

标签: sql string oracle oracle11g

select 
    a.cid, a.status, c.cuid, type, d.cstcode 
from 
    co_hist a, co_all c, cus_all d 
where 
    a.cid = c.cid 
    and c.cuid = d.cuid 
    and a.seqno in (select max(seqno) 
                    from cont_hist b 
                    where a.cid in (658.22)  
                      and a.cid = b.cid)

cstcode的结果是9.122212.234.45566。我想在这一点上剪切“9.122212”并在我的其他查询中使用 - 我该怎么做?

请帮帮我

1 个答案:

答案 0 :(得分:1)

假设上,您的请求是"所有内容但不包括第二个句点字符",以下内容应该足够

SQL> with sample_data as
  2  ( select '9.122212.234.45566' cstcode from dual )
  3  select substr(cstcode,1,instr(cstcode,'.',1,2)-1)
  4  from sample_data;

SUBSTR(C
--------
9.122212