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

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"
Culwatrnca11Data AnalystAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PortletPaulEE Topic AdvisorCommented:
Typically you want to show some other value under each heading, but you give no clue as to what.

The most conventional way to "pivot data" if to use GROUP BY and aggregate functions such as MAX() e.g.

SELECT
   customerid
,  max(case when dx.line = 1 then somevaluehere end) DX_1
,  max(case when dx.line = 2 then somevaluehere end) DX_2
,  max(case when dx.line = 3 then somevaluehere end) DX_3
...
FROM sometables
GROUP BY
   customerid

{+ multiple edits, sorry)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Culwatrnca11Data AnalystAuthor 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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SQL

From novice to tech pro — start learning today.