테이블이 3 개 있다고 가정 해 봅시다. transaction
, cust_type_1
, cust_type_2
.데이터에 따라 오라클에 가입 할 테이블을 선택하십시오.
Transaction
Cust_type char - type of customer which can be 1 or 2
Cust_id number - id from their respective table i.e. cust_type_1 and cust_type2
Amount number - amount
Cust_type_1
ct1_id number - id(pk)
ct1_name varchar - customer name
Cust_type_2
ct2_id number - id(pk)
ct2_name varchar - customer name
이제 이름과 금액 만 볼 수있는보기를 만들고 싶습니다.
select COND_JOINED_TABLE_ALIAS.name,t.amount
from transaction t
join case when t.type = 1 JOIN CUST_TYPE_1
else JOIN CUST_TYPE_2 END AS COND_JOINED_TABLE_ALIAS
데이터 유형에 따라 조건부 조인을 수행하려면 어떻게해야합니까? 예이 사용 사례를 피하기 위해 더 나은 구조가 있음을 알고 있습니다. 그러나 이것은 예에 불과합니다. 도움이 될 것입니다.
오히려 내측보다 가입 상기 질의가 모두 존재하지 않는 transaction.cust_id 값에 대한 기록을 산출하지 않으므로 가입 사용될 수있다 cust_type_1 및 cust_type_2 테이블 –