Thanks for your kind respond. :)
My data is complicated, so actually i have query like this before, refer to some solution i found in this forum.
It's run but run so long and doesn't give me any result.
WITH RECURSIVE SEGMENT_LIST( CUST_NO, LOB_ID, DESCRIPTION, LVL)
AS
(
SELECT a.HOST_CUST_NO, c.SUB_LOB_ID, MIN(c.SUB_LOB_DESC) (VARCHAR(1000)), 1
FROM SIT03_EDW_ACL_SEM_VR.DIM_HOST_CUST a
JOIN SIT03_EDW_ACL_SEM_VR.FACT_LN_MTRC_MTHLY_MSTR b ON a.BUSN_DT = b.BUSN_DT AND a.HOST_CUST_ID = b.HOST_CUST_ID
JOIN SIT03_EDW_ACL_SEM_VR.DIM_LOB c ON a.BUSN_DT = c.BUSN_DT
GROUP BY 1,2
UNION ALL
SELECT a.HOST_CUST_NO, c.SUB_LOB_ID, c.SUB_LOB_DESC || ',' || DESCRIPTION, LVL+1
FROM SIT03_EDW_ACL_SEM_VR.DIM_HOST_CUST a
JOIN SIT03_EDW_ACL_SEM_VR.FACT_LN_MTRC_MTHLY_MSTR b ON a.BUSN_DT = b.BUSN_DT AND a.HOST_CUST_ID = b.HOST_CUST_ID
JOIN SIT03_EDW_ACL_SEM_VR.DIM_LOB c ON a.BUSN_DT = c.BUSN_DT
INNER JOIN SEGMENT_LIST d ON a.HOST_CUST_NO = CUST_NO
AND c.SUB_LOB_ID = LOB_ID
AND c.SUB_LOB_DESC > DESCRIPTION
)
SELECT a.CUST_NO, a.DESCRIPTION
FROM SEGMENT_LIST a
JOIN SIT03_EDW_ACL_SEM_VR.DIM_HOST_CUST c ON a.CUST_NO = c.HOST_CUST_NO
JOIN SIT03_EDW_ACL_SEM_VR.DIM_LOB d ON a.LOB_ID = d.SUB_LOB_ID
WHERE c.BUSN_DT ='2012-10-31' AND HOST_CUST_NO in('0006158010')
I want to ask you, could i use join in WITH RECURSIVE, like i do in my query?
And is there another way to get the result without using WITH RECURSIVE? Because actually i want to display the data in Cognos not in Teradata, and Cognos doesn't know WITH RECURSIVE.
Thank you, i'm really new with this stuff.
Thanks for your kind respond. :)
My data is complicated, so actually i have query like this before, refer to some solution i found in this forum.
It's run but run so long and doesn't give me any result.
I want to ask you, could i use join in WITH RECURSIVE, like i do in my query?
And is there another way to get the result without using WITH RECURSIVE? Because actually i want to display the data in Cognos not in Teradata, and Cognos doesn't know WITH RECURSIVE.
Thank you, i'm really new with this stuff.