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

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 14773

Trending Articles



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