-1

我正在努力在我的宇宙中创建三个变量。这些变量是应用程序、操作系统和物理位置。我遇到的问题是所有这三个都是从同一张表中提取的,并且它们都在值内。

所以表BMC_CORE_BMC_BASERELATIONSHIP有变量名称。当名称等于时,我试图提取操作系统的所有目标实例 ID SYSTEMOS

我的第一个客人是使用派生表,这三个表中的每一个都是一个单独的表,具有以下编码

“操作系统关系”导出表

SELECT
BMC_CORE_BMC_BASERELATIONSHIP.DESTINATION_INSTANCEID 
FROM 
BMC_CORE_BMC_BASERELATIONSHIP 
Where 
BMC_CORE_BMC_BASERELATIONSHIP.Name = 'SYSTEMOS'

“物理位置关系”导出表

SELECT
BMC_CORE_BMC_BASERELATIONSHIP.DESTINATION_INSTANCEID 
FROM 
BMC_CORE_BMC_BASERELATIONSHIP 
Where 
BMC_CORE_BMC_BASERELATIONSHIP.Name = 'ELEMENTLOCATION'

“应用关系”派生表

SELECT
BMC_CORE_BMC_BASERELATIONSHIP.DESTINATION_INSTANCEID 
FROM 
BMC_CORE_BMC_BASERELATIONSHIP 
Where 
BMC_CORE_BMC_BASERELATIONSHIP.Name = 'APPLICATIONSYSTEMCOMPUTER'

但是,当我尝试使用以下语法拉入变量时,Webi 中只会显示其中一个变量。我发现其他人都被取消了。

App Var

Case 
WHEN CI_RELATED_CI.INSTANCEID ="Applications Relationship".DESTINATION_INSTANCEID
Then CI_RELATED_CI.NAME
END

Location Var

CASE
WHEN CI_RELATED_CI.INSTANCEID = "Physical Location Relationship".DESTINATION_INSTANCEID
THEN CI_RELATED_CI.NAME
END

OS Var

Case 
WHEN CI_RELATED_CI.INSTANCEID ="Operating System Relationship".DESTINATION_INSTANCEID
Then CI_RELATED_CI.NAME
END

我试图想办法将所有这些作为单独的变量放入一个派生表中,但到目前为止我一直没有成功。任何想法或建议将不胜感激。我是新来的,所以让我知道是否有什么可以让我的问题变得更好。

4

3 回答 3

0
am able to get the out put 

create table BMC_CORE_BMC_BASERELATIONSHIP (name1 varchar2(100),id number);

insert into BMC_CORE_BMC_BASERELATIONSHIP (name1,id) values('SYSTEMOS',1);

insert into BMC_CORE_BMC_BASERELATIONSHIP (name1,id) values('ELEMENTLOCATION',2);

insert into BMC_CORE_BMC_BASERELATIONSHIP (name1,id) values('APPLICATIONSYSTEMCOMPUTER',3);

select Case 
WHEN Name1 = 'SYSTEMOS'
Then id
WHEN Name1 = 'ELEMENTLOCATION'
Then id
When Name1 = 'APPLICATIONSYSTEMCOMPUTER'
Then id
Else id
END
from BMC_CORE_BMC_BASERELATIONSHIP ;
o/p #
1
2
3

select Decode(Name1,'SYSTEMOS',id,'ELEMENTLOCATION',id,'APPLICATIONSYSTEMCOMPUTER',id,id) 
from BMC_CORE_BMC_BASERELATIONSHIP;
o/p #
1
2
3
于 2013-01-17T20:56:37.367 回答
0
you can use case like below or Decode, 

select Case 
WHEN BMC_CORE_BMC_BASERELATIONSHIP.Name = 'SYSTEMOS'
Then BMC_CORE_BMC_BASERELATIONSHIP.DESTINATION_INSTANCEID
WHEN BMC_CORE_BMC_BASERELATIONSHIP.Name = 'ELEMENTLOCATION'
Then BMC_CORE_BMC_BASERELATIONSHIP.DESTINATION_INSTANCEID
When BMC_CORE_BMC_BASERELATIONSHIP.Name = 'APPLICATIONSYSTEMCOMPUTER'
Then BMC_CORE_BMC_BASERELATIONSHIP.DESTINATION_INSTANCEID
Else 'Ur Comments'
END
from BMC_CORE_BMC_BASERELATIONSHIP;

or Decode 

select Decode( BMC_CORE_BMC_BASERELATIONSHIP.Name,'SYSTEMOS',BMC_CORE_BMC_BASERELATIONSHIP.DESTINATION_INSTANCEID,'ELEMENTLOCATION',BMC_CORE_BMC_BASERELATIONSHIP.DESTINATION_INSTANCEID,'APPLICATIONSYSTEMCOMPUTER',BMC_CORE_BMC_BASERELATIONSHIP.DESTINATION_INSTANCEID,else) from BMC_CORE_BMC_BASERELATIONSHIP;
于 2013-01-17T20:29:05.787 回答
0

不确定我是否正确理解您,这就是您想要的... 这是 Oracle 示例,其中每列都有自己的名称或标签。您可以将表创建为选择 - 只需在选择之前添加创建表,您的列名将是标签名称:

SELECT ename, empno, 
   (CASE deptno WHEN 10 THEN 'Accounting' END) dept10
 , (CASE deptno WHEN 20 THEN 'Research' END)   dept20
 , (CASE deptno WHEN 30 THEN 'Sales' END)      dept30
 , (CASE deptno WHEN 40 THEN 'Operations' END) dept40
FROM scott.emp
ORDER BY ename
/
ENAME   EMPNO   DEPT10      DEPT20     DEPT30     DEPT40
---------------------------------------------------------------------
ADAMS   7876                Research        
ALLEN   7499                           Sales    
BLAKE   7698                           Sales    
CLARK   7782    Accounting          
.....
于 2013-01-17T21:46:00.663 回答