We help IT Professionals succeed at work.

Teradata SQL - Is it possible to take each line item and turn into column headers.

104 Views
Last Modified: 2017-03-16
I have this code which displays each DX number in one column.  I would like these to show in 5 different columns as the headers, is that possible?

,case
      when dx.line = 1 then 'DX_1'      
      when dx.line = 2 then 'DX_2'      
            when dx.line = 3 then 'DX_3'      
            when dx.line = 4 then 'DX_4'      
            when dx.line = 5 then 'DX_5'      
            else 'N/A'      
end as "DX_Line"
Comment
Watch Question

EE Topic Advisor
CERTIFIED EXPERT
Most Valuable Expert 2014
Awarded 2013
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Culwatrnca11Data Analyst

Author

Commented:
Thanks PortletPaul, this was very helpful.  I was able to obtain a report utilizing this format and the usage of max(case when...  to create a sub subquery in my existing report.