加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

sql – 如果select中的语句(ORACLE)

发布时间:2020-12-12 06:51:39 所属栏目:MsSql教程 来源:网络整理
导读:嗨,我只是选择并且工作得很好: select 'CARAT Issue Open' issue_comment,i.issue_id,i.issue_status,i.issue_title,i.ISSUE_summary,i.issue_description,i.severity,gcrs.Area_name,gcrs.sector_name,substr(gcrs.stream_name,1,case when instr(gcrs.str
嗨,我只是选择并且工作得很好:
select 'CARAT Issue Open' issue_comment,i.issue_id,i.issue_status,i.issue_title,i.ISSUE_summary,i.issue_description,i.severity,gcrs.Area_name,gcrs.sector_name,substr(gcrs.stream_name,1,case when instr(gcrs.stream_name,' (')=0 then 100 else instr(gcrs.stream_name,' (')-1 end) ISSUE_DIVISION,case when gcrs.STREAM_NAME like 'NON-GT%' THEN 'NON-GT' ELSE gcrs.STREAM_NAME END as ISSUE_DIVISION_2


from table(f_carat_issues_as_of('31/MAR/2013')) i
inner join v_gcrs_with_stream gcrs on i.segment_id = gcrs.segment_id

where UPPER(ISSUE_STATUS) like '%OPEN%'

现在我想调用两列:
ISSUE_DIVISION和ISSUE_DIVISION_2

如果它们在新列中相等则应为值1,如果不相等则应为0,

我该怎么做 ?

我的完整代码:

select 'CARAT Issue Open' issue_comment,case when gcrs.STREAM_NAME like 'NON-GT%' THEN 'NON-GT' ELSE gcrs.STREAM_NAME END as ISSUE_DIVISION_2


from table(f_carat_issues_as_of('31/MAR/2013')) i
inner join v_gcrs_with_stream gcrs on i.segment_id = gcrs.segment_id

where UPPER(ISSUE_STATUS) like '%OPEN%' and 

CASE WHEN ISSUE_DIVISION = ISSUE_DIVISION_2 THEN 
     CASE WHEN  ISSUE_DIVISION is null then "Null Value found"
     Else 1 End
ELSE 0 END As Issue_Division_Result

但我在网上得到错误:
ELSE 0 END作为Issue_Division_Result

ORA-00920:无效的关系运算符:(

解决方法

SELECT (CASE WHEN ISSUE_DIVISION = ISSUE_DIVISION_2 THEN 1 ELSE 0 END) AS ISSUES
    --  <add any columns to outer select from inner query> 
  FROM
 (  -- your query here --
   select 'CARAT Issue Open' issue_comment,....,...,' (')=0 then 100 else  instr(gcrs.stream_name,case when gcrs.STREAM_NAME like 'NON-GT%' THEN 'NON-GT' ELSE gcrs.STREAM_NAME END as ISSUE_DIVISION_2
     from ....
    where UPPER(ISSUE_STATUS) like '%OPEN%'
 )
 WHERE... -- optional --

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读