0
我試圖執行以下查詢:使用一個SELECT語句中的甲骨文
SELECT pt.prod_desc"Description",
(
CASE
WHEN pt.prod_level='2'
THEN 'Product'
WHEN pt.prod_level='4'
THEN 'Sub-Product'
WHEN pt.prod_level='5'
THEN 'Service'
ELSE 'N/A'
END)"Level", prod_id"CKC ID", isactive"Active", updt_usr_sid"Last Updated By",
updt_ts"LAst Updated Date",
(CASE WHEN pt.prod_level='5' THEN parent_prod_id ELSE null END)"Parent Sub-Product CKC ID",
(CASE WHEN Level='Service' THEN (Select prod_desc from dims_prod_type where prod_id= parent_prod_id) ELSE 'N/A' END)
FROM dims_prod_type pt
ORDER BY prod_desc;
我收到以下錯誤: 錯誤報告:
SQL Error: ORA-01788: CONNECT BY clause required in this query block 01788. 00000 - "CONNECT BY clause required in this query block" *Cause: *Action:
我修改我的查詢如下:
SELECT pt.prod_desc"Description",
(
CASE
WHEN pt.prod_level='2'
THEN 'Product'
WHEN pt.prod_level='4'
THEN 'Sub-Product'
WHEN pt.prod_level='5'
THEN 'Service'
ELSE 'N/A'
END)"Level", prod_id"CKC ID", isactive"Active", updt_usr_sid"Last Updated By",
updt_ts"LAst Updated Date",
(CASE WHEN pt.prod_level='5' THEN parent_prod_id ELSE null END)"Parent Sub-Product CKC ID",
(CASE WHEN Level='Service' THEN (Select prod_desc from dims_prod_type where connect by prior prod_id=parent_prod_id) ELSE 'N/A' END)
FROM dims_prod_type pt
ORDER BY prod_desc;
仍然收到相同的錯誤。
level關鍵字爲oracle保留,嘗試使用別名alias –
使用別名dist在同一個表 –
的兩個實例之間的苦苦掙扎。謝謝!如果我改變它的作品的別名。 – Ankit