Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 27759

Dynamic Column Name - response (6) by saurabhkamath

$
0
0

 

REPLACE PROCEDURE SP_TEMP ()

CALL DBC.SYSEXECSL(

'REPLACE VIEW TEMP_V

AS

SELECT ID,ARTICLE,

CASE YEAR_MONTH

WHEN CAST(CAST(CAST(DATE AS FORMAT 'YYYYMM')AS CHAR(6))AS INT)

THEN AMOUNT

ELSE 0

END AS "REVENUE-'||CAST(CAST(DATE AS FORMAT 'YYYYMM')AS CHAR(6))||'",

CASE YEAR_MONTH

WHEN CAST(CAST(CAST(ADD_MONTHS(DATE,-1) AS FORMAT 'YYYYMM')AS CHAR(6))AS INT)

THEN AMOUNT

ELSE 0

END AS "REVENUE-'||CAST(CAST(ADD_MONTHS(DATE,-1) AS FORMAT 'YYYYMM')AS CHAR(6))||'"

FROM SALES_HIST');

 

 

 

CALL SP_TEMP ();

 

 

SELECT * FROM TEMP_V;


Viewing all articles
Browse latest Browse all 27759

Trending Articles