How can column names be populated with current_date?

Database
Enthusiast

How can column names be populated with current_date?

Hi all- 

I currently have SQL that produces 5 columns:

'Media Type' | 'Day1' | 'Day2' | 'Day3' | 'Day4' |

How can I have my select statement produce column names with the current date  in them?

Example:

'Media Type' | 'current_date' | 'current_date - 1' | 'current_date - 2' | 'current_date - 3' |

SELECT

'Media Type'

, 'current_date' 

, 'current_date - 1' 

, 'current_date - 2'

,'current_date - 3'

any help would be greatly appreicated, thanks in advance!

2 REPLIES
WAQ
Enthusiast

Re: How can column names be populated with current_date?

SELECT

'Media Type' AS Media_Type

,current_date AS Day1

,current_date - 1 AS Day2

,current_date - 2 AS Day3

,current_date - 3 AS Day4

Enthusiast

Re: How can column names be populated with current_date?

Thanks WAQ, but I dont want the value for the column to be the date, just the name of the column. 

Select Distinct

a.MEDIA_CD as "Media Type"

,Q1.DNS_COUNT as Day1 <--- I need this field Q1.DNS_COUNT's value to display in a column labeled 'current_date-1'

,Q2.DNS_COUNT as Day2 <--- I need this field Q2.DNS_COUNT's value to display in a column labeled 'current_date-2'

,Q3.DNS_COUNT as Day3 <-- I need this field Q3.DNS_COUNT's value to display in a column labeled 'current_date-3'

,Q4.DNS_COUNT as Day4 <--- I need this field Q4.DNS_COUNT's value to display in a column labeled 'current_date-4'