SELECT (COUNT (DISTINCT RP.REGISTER_ID), CAST (RPE.CEMAIL_DATETM AS DATE)
FROM
SCHEMA_1.REGISTER_TBL RP
INNER JOIN
SCHEMA_2.MPROGRAM MP
ON RP.MPRG_NBR= MP.MPRG_NBR
INNER JOIN
SCHEMA_2.RPEMAIL_ADDR RPE
ON RP.REGISTER_ID=RPE.REGISTER_ID
AND RP.MPRG_NBR=RPE.MPRG_NBR
WHERE RP.MPRG_NBR IN (100)
AND RPE.SUBSET_ID ='O'
AND RPE.CEMAIL_DATETM BETWEEN (CURRENT_DATE -7) and CURRENT_DATE
GROUP BY CAST ( RPE.CEMAIL_DATETM AS DATE)
ORDER BY CAST (RPE.CEMAIL_DATETM AS DATE)
-----------------------------------------------------------------------------------------------------------
SELECT (COUNT (DISTINCT RP.REGISTER_ID), CAST (RP.REGISTER_DATETM AS DATE)
FROM
SCHEMA_1.REGISTER_TBL RP
INNER JOIN
SCHEMA_2.MPROGRAM MP
ON RP.MPRG_NBR= MP.MPRG_NBR
INNER JOIN
SCHEMA_2.RPEMAIL_ADDR RPE
ON RP.REGISTER_ID=RPE.REGISTER_ID
AND RP.MPRG_NBR=RPE.MPRG_NBR
WHERE
WHERE RP.MPRG_NBR IN (100)
AND RPE.SUBSET_ID ='I'
AND RP.STATUS_ID = 'ACTION'
AND RP.REGISTER_DATETM BETWEEN (CURRENT_DATE -7) and CURRENT_DATE
GROUP BY CAST ( RP.REGISTER_DATETM AS DATE)
ORDER BY CAST (RP.REGISTER_DATETM AS DATE)
------------------------------------------------------------------------
SELECT (COUNT (DISTINCT RP.REGISTER_ID), CAST (RP.REGISTER_DATETM AS DATE) /* QUERY FOR (9999) */
FROM
SCHEMA_1.REGISTER_TBL RP
INNER JOIN
SCHEMA_2.MPROGRAM MP
ON RP.MPRG_NBR= MP.MPRG_NBR
INNER JOIN
SCHEMA_2.RPEMAIL_ADDR RPE
ON RP.REGISTER_ID=RPE.REGISTER_ID
AND RP.MPRG_NBR=RPE.MPRG_NBR
LEFT OUTER JOIN
ECTRL.LCTRL LC
ON CAST(RP.SSOURCE AS DECIMAL(16,0)) = LC.LID
AND LC.LTYPE = 'ECTR'
LEFT OUTER JOIN
ECTRL.LCTRL SC
ON LC.SID = SC.SID
WHERE
RP.MPRG_NBR IN (100)
AND LC.SID IN (9999)
AND RPE.SUBSET_ID ='I'
AND RP.STATUS_ID = 'ACTION'
AND RP.REGISTER_DATETM BETWEEN (CURRENT_DATE -7) and CURRENT_DATE
GROUP BY CAST ( RP.REGISTER_DATETM AS DATE)
ORDER BY CAST (RP.REGISTER_DATETM AS DATE)
-----------------------------------------------------------------------
SELECT (COUNT (DISTINCT RP.REGISTER_ID), CAST (RP.REGISTER_DATETM AS DATE) /* QUERY FOR (8888) */
FROM
SCHEMA_1.REGISTER_TBL RP
INNER JOIN
SCHEMA_2.MPROGRAM MP
ON RP.MPRG_NBR= MP.MPRG_NBR
INNER JOIN
SCHEMA_2.RPEMAIL_ADDR RPE
ON RP.REGISTER_ID=RPE.REGISTER_ID
AND RP.MPRG_NBR=RPE.MPRG_NBR
LEFT OUTER JOIN
ECTRL.LCTRL LC
ON CAST(RP.SSOURCE AS DECIMAL(16,0)) = LC.LID
AND LC.LTYPE = 'ECTR'
LEFT OUTER JOIN
ECTRL.LCTRL SC
ON LC.SID = SC.SID
WHERE
RP.MPRG_NBR IN (100)
AND LC.SID IN (8888)
AND RPE.SUBSET_ID ='I'
AND RP.STATUS_ID = 'ACTION'
AND RP.REGISTER_DATETM BETWEEN (CURRENT_DATE -7) and CURRENT_DATE
GROUP BY CAST ( RP.REGISTER_DATETM AS DATE)
ORDER BY CAST (RP.REGISTER_DATETM AS DATE)
--------------------------------------------------------------------------------
SELECT COUNT (DISTINCT RP.MCPR_ID), CAST (CA.CAS_DATETM AS DATE)
FROM
SCHEMA_1.REGISTER_TBL RP
INNER JOIN
SCHEMA_1.Customer_TBL CA
ON RP.REGISTER_ID = CA.REGISTER_ID
WHERE
CA.MPRG_NBR IN (100)
AND CA.L_NBR IN (215)
AND CA.T_CODE IN ('Rose_A')
AND CA.CAS_DATETM BETWEEN (CURRENT_DATE -7) and CURRENT_DATE
GROUP BY CAST (CA.CAS_DATETM AS DATE)
ORDER BY CAST (CA.CAS_DATETM AS DATE)
----------------------------------------------------------------------------------------------------------
SELECT COUNT (DISTINCT RP.MCPR_ID), CAST (CA.CAS_DATETM AS DATE)
FROM
SCHEMA_1.REGISTER_TBL RP
INNER JOIN
SCHEMA_1.Customer_TBL CA
ON RP.REGISTER_ID = CA.REGISTER_ID
WHERE
CA.MPRG_NBR IN (100)
AND CA.L_NBR IN (215)
AND CA.T_CODE IN ('Rose_B')
AND CA.CAS_DATETM BETWEEN (CURRENT_DATE -7) and CURRENT_DATE
GROUP BY CAST (CA.CAS_DATETM AS DATE)
ORDER BY CAST (CA.CAS_DATETM AS DATE)
--------------------------------------------------------------------------------------------------------------------
SELECT COUNT (DISTINCT RP.MCPR_ID), CAST (CA.CAS_DATETM AS DATE)
FROM
SCHEMA_1.REGISTER_TBL RP
INNER JOIN
SCHEMA_1.Customer_TBL CA
ON RP.REGISTER_ID = CA.REGISTER_ID
WHERE
CA.MPRG_NBR IN (100)
AND CA.L_NBR IN (215)
AND CA.T_CODE IN ('Rose_C')
AND CA.CAS_DATETM BETWEEN (CURRENT_DATE -7) and CURRENT_DATE
GROUP BY CAST (CA.CAS_DATETM AS DATE)
ORDER BY CAST (CA.CAS_DATETM AS DATE)
---------------------------------------------------------------------------------------------------------
OUTPUT
Every Query Return Week Range of Data with TWO Columns. Date Columns and Count Column.
"Data" for COUNT may or may not POPULATE for each ROW for individual Query but it will always Populate the "DATE"for each ROW.
For Example August 1, 2013 to August 7, 2013.
COUNT(Something), DATE()
1 08/01/2013 10122 08/01/2013 21 08/01/2013 2244 08/01/2013 001 08/01/2013 002 08/01/2013
08/02/2013 23445 08/02/2013 12 08/02/2013 12 08/02/2013 005 08/02/2013 003 08/02/2013
6 08/03/2013 23244 08/03/2013 54 08/03/2013 08/03/2013 08/03/2013 004 08/03/2013
08/04/2013 08/04/2013 33 08/04/2013 054 08/04/2013 123 08/04/2013 005 08/04/2013
8 08/05/2013 45656 08/05/2013 01 08/05/2013 543 08/05/2013 183 08/05/2013 08/05/2013
10 08/06/2013 08/06/2013 09 08/06/2013 08/06/2013 186 08/06/2013 922 08/06/2013
55 08/07/2013 13545 08/07/2013 65 08/07/2013 184 08/07/2013 184 08/07/2013 988 08/07/2013
There are 14 Columns all togateher, If I were to RUN each individual Query seperately. After Combining all Queries I would like to have All DATE columns
should be Merge to 1 COLUMN and 7 DATA COLUMN. TOTAL of 8 COLUMN.
I would like to do DATA DUMP of my SINGLE COMBINE QUERY TO a TEMP TABLE that would continue to APPEND each Week. All above Queries are from VIEWS. No Table Access is available.
-----------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------
-----------------------------------------------------------------------
--------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------
OUTPUT
Every Query Return Week Range of Data with TWO Columns. Date Columns and Count Column.
"Data" for COUNT may or may not POPULATE for each ROW for individual Query but it will always Populate the "DATE"for each ROW.
For Example August 1, 2013 to August 7, 2013.
COUNT(Something), DATE()
1 08/01/2013 10122 08/01/2013 21 08/01/2013 2244 08/01/2013 001 08/01/2013 002 08/01/2013
08/02/2013 23445 08/02/2013 12 08/02/2013 12 08/02/2013 005 08/02/2013 003 08/02/2013
6 08/03/2013 23244 08/03/2013 54 08/03/2013 08/03/2013 08/03/2013 004 08/03/2013
08/04/2013 08/04/2013 33 08/04/2013 054 08/04/2013 123 08/04/2013 005 08/04/2013
8 08/05/2013 45656 08/05/2013 01 08/05/2013 543 08/05/2013 183 08/05/2013 08/05/2013
10 08/06/2013 08/06/2013 09 08/06/2013 08/06/2013 186 08/06/2013 922 08/06/2013
55 08/07/2013 13545 08/07/2013 65 08/07/2013 184 08/07/2013 184 08/07/2013 988 08/07/2013
There are 14 Columns all togateher, If I were to RUN each individual Query seperately. After Combining all Queries I would like to have All DATE columns
should be Merge to 1 COLUMN and 7 DATA COLUMN. TOTAL of 8 COLUMN.
I would like to do DATA DUMP of my SINGLE COMBINE QUERY TO a TEMP TABLE that would continue to APPEND each Week. All above Queries are from VIEWS. No Table Access is available.