Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

Combine Multiple Select Statements - response (10) by MBSconnection

$
0
0

Thanks Dieter,
The code is not working, I made a little change.

SELECT t1.datetm, t1,cnt, t2.cnt
FROM
 ( 
 SELECT COUNT(DISTINCT RP.REGIS_PRSNA_ID) AS cnt, 
 CAST (RP.REGIS_DATETM AS DATE) AS datetm
FROM
        iCRM_LOAD.REGIS_PRSNA RP
INNER JOIN
        iCRM.MKTNG_PGM MP
        ON RP.MKTNG_PGM_NBR = MP.MKTNG_PGM_NBR
INNER JOIN
        iCRM.REGIS_PRSNA_EMAIL_ADDR RPE
        ON RP.REGIS_PRSNA_ID = RPE.REGIS_PRSNA_ID
        AND RP.MKTNG_PGM_NBR = RPE.MKTNG_PGM_NBR
WHERE
        RP.MKTNG_PGM_NBR IN (115)
        AND RPE.SUBSCRPTN_OPT_IND = 'I'
        AND RP.PRSNA_STATUS_CODE = 'AC' 
AND RP.REGIS_DATETM BETWEEN (CURRENT_DATE -7) and CURRENT_DATE  
GROUP BY CAST (RP.REGIS_DATETM  AS DATE)
  ) AS t1
   
JOIN
 (
     
SELECT COUNT (DISTINCT RP.REGIS_PRSNA_ID) AS cnt,
	 CAST (RP.REGIS_DATETM AS DATE) AS datetm
FROM
        iCRM_LOAD.REGIS_PRSNA RP
INNER JOIN
        iCRM.MKTNG_PGM MP
        ON RP.MKTNG_PGM_NBR = MP.MKTNG_PGM_NBR
INNER JOIN
        iCRM.REGIS_PRSNA_EMAIL_ADDR RPE
        ON RP.REGIS_PRSNA_ID = RPE.REGIS_PRSNA_ID
        AND RP.MKTNG_PGM_NBR = RPE.MKTNG_PGM_NBR

LEFT OUTER JOIN
                ETL_CTRL.LOAD_CONTROL LC
                ON CAST(RP.SYS_SOURCE AS DECIMAL(18,0)) = LC.LOAD_ID
                AND LC.LOAD_TYPE = 'ETL'
LEFT OUTER JOIN
                ETL_CTRL.SOURCE_CONTROL SC
                ON LC.SOURCE_ID = SC.SOURCE_ID
WHERE
                RP.MKTNG_PGM_NBR IN (115)
                AND LC.SOURCE_ID IN (1213)
        AND RPE.SUBSCRPTN_OPT_IND = 'I'
        AND RP.PRSNA_STATUS_CODE = 'AC'
		AND RP.REGIS_DATETM BETWEEN (CURRENT_DATE -7) and CURRENT_DATE
GROUP BY CAST (RP.REGIS_DATETM AS DATE)
) AS t2
 ON t1.datetm = t2.datetm
   

Kindly, Look at it.
Select Failed. 5628: Column t1 not found in t2 or t1
Regards,
MBC


Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>