我有這樣一個查詢,在一個單獨的作業表中作業。
SELECT
location_key AS carrier_company_name,
FROM INGEST.LOCATION_
JOIN INGEST.LOAD_
ON INGEST.LOAD_.dwh_masterclient_id = INGEST.LOCATION_.dwh_masterclient_id
現在,我想在另一個查詢中使用它。所以基本上,我想從LOAD表中選擇dwh_masterclient_id,然后我想從LOCATION表中選擇the location_key AS carrier_company_name,然后根據兩個表中存在的dwh_masterclient_ids進行連接。
我正在嘗試這樣做
USE DATABASE PROD_DWH;
SELECT
cast(dwh_masterclient_id as smallint) AS dwh_masterclient_id。
(SELECT)
呼叫中心
FROM INGEST.LOCATION_
JOIN INGEST.LOAD_
ON INGEST.LOAD_.dwh_masterclient_id = INGEST.LOCATION_.dwh_masterclient_id)。)
1 as exception_codes
FROM INGEST.LOAD_
但是它給了我一個錯誤
Single-row subquery returns more than one row。
uj5u.com熱心網友回復:
為了允許幾個位置行,跳過子查詢,做一個LEFT JOIN來代替。類似于:
SELECT cast(dwh_masterclient_id as smallint) AS dwh_masterclient_id,
location_key,
1 as exception_codes
FROM INGEST.LOAD_
LEFT JOIN INGEST.LOCATION_
ON INGEST.LOAD_.dwh_masterclient_id = INGEST.LOCATION_.dwh_masterclient_id
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/307797.html
標籤:
