如何加入子查询内连接

时间:2014-09-24 11:43:23

标签: oracle oracle10g

“%s:无效标识符”错误我得到以下查询 如何在不同的键值上连接两个子连接

 select * from 
(select 

b.SYS_ID as SYS_ID1,a.IBNR_CALC_YM,
from
ibnr_pend_claims a Inner Join ibnr_prod_mapping b On a.sys_ID= b.Sys_ID and a.ibnr_prod = b.ibnr_prod)  abc
Inner Join
(select * from 
    (select 
--Count(*)
d.SYS_ID as SYS_ID1,c.IBNR_CALC_YM,
from
ibnr_prod_mapping d Inner Join ibnr_paid_claims_exp c On c.sys_ID= d.Sys_ID and c.ibnr_prod = d.ibnr_prod) def)
on   abc.SYS_ID = def.SYS_ID;

CREATE TABLE "IBNR_PEND_CLAIMS" ( 
  "SYS_ID" CHAR(1 BYTE) NOT NULL ENABLE,
  "IBNR_CALC_YM" CHAR(6 BYTE) NOT NULL ENABLE,
  "IBNR_PROD" CHAR(6 BYTE) NOT NULL ENABLE 
);
CREATE TABLE "IBNR_PAID_CLAIMS" (
  "SYS_ID" CHAR(1 BYTE) NOT NULL ENABLE, 
  "IBNR_CALC_YM" CHAR(6 BYTE) NOT NULL ENABLE, 
  "IBNR_PROD" CHAR(6 BYTE) NOT NULL ENABLE 
);
CREATE TABLE "ibnr_prod_mapping" ( 
  "SYS_ID" CHAR(1 BYTE) NOT NULL ENABLE,
  "IBNR_CALC_YM" CHAR(6 BYTE) NOT NULL ENABLE,
  "IBNR_PROD" CHAR(6 BYTE) NOT NULL ENABLE 
);

2 个答案:

答案 0 :(得分:1)

试试这个:

select * 
  from 
(select b.SYS_ID as SYS_ID1,a.IBNR_CALC_YM
  from ibnr_pend_claims a 
 Inner Join ibnr_prod_mapping b On a.sys_ID= b.Sys_ID and a.ibnr_prod = b.ibnr_prod
) abc
 Inner Join
(select * from 
    (select d.SYS_ID as SYS_ID1,c.IBNR_CALC_YM
       from ibnr_prod_mapping d 
      Inner Join ibnr_paid_claims_exp c On c.sys_ID= d.Sys_ID and c.ibnr_prod = d.ibnr_prod
    )
) def on abc.SYS_ID1 = def.SYS_ID1

答案 1 :(得分:0)

select *  from 
(select b.SYS_ID as SYS_ID1,a.IBNR_CALC_YM from ibnr_pend_claims a 
 Inner Join ibnr_prod_mapping b On a.sys_ID= b.Sys_ID and a.ibnr_prod = b.ibnr_prod) abc
 Inner Join
(select d.SYS_ID as SYS_ID1,c.IBNR_CALC_YM from ibnr_prod_mapping d 
      Inner Join ibnr_paid_claims_exp c On c.sys_ID= d.Sys_ID and c.ibnr_prod = d.ibnr_prod) def on abc.SYS_ID1 = def.SYS_ID1;