troubleshooting Question

SQL that will turn the rows in to columnsin date format

Avatar of chandan m
chandan m asked on
Microsoft SQL ServerSQL
28 Comments1 Solution123 ViewsLast Modified:
Hi All,

I have an output with list of account # and there are list mails that are mailed to each account that are displayed in rows, For example below is the output i have,

AccountNo         Letter Date
987654                 1/1/2017
987654                  1/10/2017
987654                   1/21/2017
987654                   01/22/2017
987654                   02/21/2017
987654                    03/2/2017

What I’m looking for is some SQL that will turn the rows in to columns, so there is only one row per Account number and number the LetterDate in order of when they were mailed.

So something like this:
AccountNo        Letter 1       Letter 2         Letter 3         Letter 4         Letter 5           Letter 6
987654             1/1/2017    1/10/2017     1/21/2017      02/4/2017     2/17/2017     3/3/2017

Can anybody help me with the solution.
Jeff Darling
Developer Analyst

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 28 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 28 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros