-2
이 쿼리를 실행하려고하는데 어떻게 든 하단 부분 레이블 B가 작동하지 않습니다.오라클 쿼리가 잘못 된 것을 보지 못합니다.
나는 오라클을 처음 접했고 나는 틀린 것을 보지 못했다. 누구든지 나를 도울 수 있습니까? 대단히 감사하겠습니다.
영업 사원이 연결되어 있지 않은 경우 데이터를 반환하지 않습니다. 이는 여전히 기본 고객에 대한 정보를 반환해야합니다.
SELECT DISTINCT X.ship_sales_representative_id,
X.ship_sales_representative_name,
X.ship_sales_regional_name,
X.ship_sales_regional_head,
B.bl_customer_representative_id,
X.sp_customer_representative_id,
B.bill_customer_id,
X.ship_customer_id,
B.bill_customer_address_suffix,
X.ship_customer_address_suffix,
B.bill_customer_name,
X.ship_customer_name,
B.bill_customer_address,
X.ship_customer_address,
B.bill_customer_city,
X.ship_customer_city,
B.bill_customer_statecode,
X.ship_customer_statecode,
B.bill_customer_zipcode,
X.ship_customer_zipcode,
B.bill_customer_phonenumber,
X.ship_customer_phonenumber,
B.bill_customer_faxnumber,
X.ship_customer_faxnumber,
B.bill_customer_email,
X.ship_customer_email,
B.bill_customer_contact,
X.ship_customer_contact
FROM (SELECT DISTINCT S.rep_id Ship_Sales_Representative_ID,
S.rep_name Ship_Sales_Representative_Name,
S.reg_name Ship_Sales_Regional_Name,
S.reg_head Ship_Sales_Regional_Head,
C.rep_id Sp_Customer_Representative_ID,
C.cust_id Ship_Customer_ID,
C.addr_suffix Ship_Customer_Address_Suffix,
C.name Ship_Customer_Name,
C.addr_ln_1 Ship_Customer_Address,
C.city Ship_Customer_City,
C.state_cd Ship_Customer_StateCode,
C.zip_cd Ship_Customer_Zipcode,
C.phone_nbr Ship_Customer_PhoneNumber,
C.fax_nbr Ship_Customer_FaxNumber,
C.email Ship_Customer_Email,
C.contact Ship_Customer_Contact
FROM mdw.customer C,
mdw.sales_org S
WHERE C.rep_id = To_char(S.rep_id, 'FM000000')
AND C.cust_id = v_cust_id
AND C.addr_suffix = v_addr_suffix) X,
(SELECT DISTINCT C.rep_id Bl_Customer_Representative_ID,
C.cust_id Bill_Customer_ID,
C.addr_suffix Bill_Customer_Address_Suffix,
C.name Bill_Customer_Name,
C.addr_ln_1 Bill_Customer_Address,
C.city Bill_Customer_City,
C.state_cd Bill_Customer_StateCode,
C.zip_cd Bill_Customer_Zipcode,
C.phone_nbr Bill_Customer_PhoneNumber,
C.fax_nbr Bill_Customer_FaxNumber,
C.email Bill_Customer_Email,
C.contact Bill_Customer_Contact
FROM mdw.customer C
WHERE C.cust_id = v_cust_id
AND C.addr_suffix = '0001') B;
아니라 점은 B.REP_ID로 시작하는이 참여 밤은있다 전체 서브 테이블이 실행 중이 아니며 NUll을 리턴하지 않습니다. 나는 특정 서브 테이블을 호출하고 결과를 얻지 못하는 방법을 얻지 못한다. 하지만 난 그냥 Selct insub 테이블을 실행하면 B가 작동 – user2795514
@ user2795514 그것은 명확하지 않다. 어떤 서브 테이블이 null을 리턴합니까? 이 서브 테이블 사이의 관계는 무엇입니까? 'INNER JOIN' 대신에'LEFT JOIN'을 사용하고자 할 수도 있습니다 - 서브 테이블 사이의 관계의 종류에 달려 있습니다 – alfasin
두 개의 테이블을 함께 연결할 수 없습니다. – user2795514