AnalysisException: Unsupported correlated subquery with grouping and/or aggregation

102 Views Asked by At

I want to join two tables in Impala from different databases.

I tried:

SELECT tl.*, pt.tran_desc_1
FROM dev_trench_m.v_transaction_label  tl
JOIN dev_trench_stg.v_posted_transaction pt
    ON tl.transaction_id = pt.transaction_id
WHERE tl.transaction_id IN
(
SELECT MAX(tl.transaction_id) FROM dev_trench_m.v_transaction_label 
WHERE tl.tran_label_code_4 IN 
    (
    "FIN0102999" --JPU Hypoteční úvěr - neupřesněno
    ,"FOD0101011" --Lidl
    ,"MON0303001" --Starobní důchod
    ,"NEM0103001" --ČEZ Distribuce, a.s.
    ,"MON0302002" --Rodičovský příspěvek
    ) 
group by tl.tran_label_code_4
)
limit 5

I got:

AnalysisException: Unsupported correlated subquery with grouping and/or aggregation: SELECT max(tl.transaction_id) FROM dev_trench_m.v_transaction_label WHERE tl.tran_label_code_4 IN ('FIN0102999', 'FOD0101011', 'MON0303001', 'NEM0103001', 'MON0302002') GROUP BY tl.tran_label_code_4

Maybe CTE table could help? But I'm not sure at all..

0

There are 0 best solutions below