What's wrong on my code here? I am getting an error from Redshift when executing these lines.
SELECT
COUNT (
DISTINCT (
CASE
WHEN EXISTS(
(
select
1
from
(
select
ci.order_no,
count(ci.booking_location_id) as cnt
from
oms_core_inventory_booking_detail ci
group by
ci.order_no
) cibd
where cibd.cnt > 1
and co.order_no = cibd.order_no
)
) THEN co.order_no
else NULL
END
)
) AS "SP受注数"
from
table co
And I am getting an error like this
This type of correlated subquery pattern is not supported due to internal error
Thank you for the incoming help.
Saleh