-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Description
Greetings!
-- WITH fails: Column alias is not specified for expression "(COUNT(CUSTOMER_ID) > 1)";
WITH d AS (
SELECT customer_id
FROM ( SELECT DISTINCT
customer_id
, id_customer_type
FROM risk.ext_counterparty_classification )
GROUP BY customer_id
HAVING Count( customer_id ) > 1 )
SELECT *
FROM risk.ext_counterparty_classification a
INNER JOIN d
on a.customer_id = d.customer_id
WHERE id_customer_type = 'Multi Financial Institution'
;
-- although SUB Select works
SELECT *
FROM risk.ext_counterparty_classification a
INNER JOIN ( SELECT customer_id
FROM ( SELECT DISTINCT
customer_id
, id_customer_type
FROM risk.ext_counterparty_classification )
GROUP BY customer_id
HAVING Count( customer_id ) > 1 ) d
ON a.customer_id = d.customer_id
WHERE id_customer_type = 'Multi Financial Institution'
;Without the HAVING clause, the WITH also works (but of course the result set would not match expectation).
Latest 2.2.232 and both queries should be the same.
Metadata
Metadata
Assignees
Labels
No labels