Hi
Need a help in rewritting the folwoing SQL which is taking more than a
day to give resultset. Is there anything wrong in this SQL coding ?
SELECT DISTINCT 214 AS BATCH_ID,
TAB1.customer_sk,
TAB1.CUSTOMER_ID,
TAB1.product_line_sk,
COUNT(DISTINCT TAB1.ACCOUNT_SK) AS COUNT
FROM SCHEMA1.TABLE1 TAB1
WHERE TAB1.acc_opened IN (SELECT datetime
from SCHEMA1.TAB2
where day between (select day-30 from SCHEMA1.TAB2 where datetime =
(SELECT batch_date FROM SCHEMA2.TAB3 WHERE BATCH = 214)) and (select
day from SCHEMA1.TAB2 where datetime = (SELECT batch_date FROM
SCHEMA2.TAB3 WHERE BATCH = 214)))
GROUP BY TAB1.customer_sk, TAB1.CUSTOMER_ID, TAB1.product_line_sk
HAVING COUNT(DISTINCT TAB1.ACCOUNT_SK) > 1