请有人解释最后一行究竟是做什么的

时间:2018-04-20 04:54:03

标签: sql oracle

SELECT A.siebel_row_id AS ASSET_ROW_ID,A.SIEBEL_STATUS ,B.STATUS AS THINDB_STATUS
FROM OR_ASSET_THINDB A ,THINDBUSER.MSI B
WHERE A.msisdn=B.msisdn`enter code here`
and b.circle='Orissa'
and DECODE(a.siebel_status,'Suspended','Active','Active','Active','Inactive','Inactive')<>b.STATUS; 

2 个答案:

答案 0 :(得分:3)

我不确定这个查询要求,但这是我的理解

<强> DECODE(siebel_status,&#39;暂停&#39;&#39;主动&#39;&#39;主动&#39;&#39;主动&#39;,&#39;无效&#39;&#39;无效&#39)
  这将起到如下作用:

case  
when siebel_status = 'Suspended' THEN 'Active'  
when siebel_status = 'Active' THEN 'Active'  
when siebel_status = 'Inactive' THEN 'Inactive'
end;

从上面返回的结果将与以下内容进行比较:
b.STATUS;

所以最后的答案可能是这样的:
if(&#39; Active&#39;,&#39; Active&#39;,&#39; Inactive&#39;)&lt;&gt; b.STATUS

答案 1 :(得分:1)

and DECODE(a.siebel_status, 
           'Suspended', 'Active',
           'Active'   ,'Active' ,
           'Inactive' ,'Inactive'
          ) <> b.STATUS;

它说:

  • 如果siebel_status被暂停,假装它活动
  • 如果siebel_status 活动,那么它仍然活动
  • 如果siebel_status 无效,则它仍然无效

然后将其与b.status值进行比较。