Question Locked

Rearrange Rows and Columns

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have a table with three columns:
AcctNbr, Type, CodeValue

Listed below is an example of the database.

AcctNbr Type CodeValue
1 MAILCODE 99
2 MAILCODE 99
3 MAILCODE 99
4 MAILCODE 90
4 MAILCODE 99
4 SEG1 O
5 MAILCODE 99
6 MAILCODE 99
7 MAILCODE 99
8 MAILCODE 99
9 MAILCODE 99
10 MAILCODE 90
11 MAILCODE 99
12 MAILCODE 99
13 MAILCODE 99
14 MAILCODE 99
15 LIST DS1
15 MAILCODE 99

There are multiple Type's for some AcctNbr's and what I want to do is
run a query on the database so that if the AcctNbr has multiple Type's
and CodesValue's it takes them and creates new columns like so:

AcctNbr MailCode_90 MailCode_99 SEG1
4 90 99 O

So on and so forth. There are multiple Type's and multiple codes that
I need to do this with for each account number. If someone could give
me a base code to try I could start somewhere. I am an SQL novice.
Thanks.

Josh

4 replies

by tony hopkinson

You'll have to hit the help, to see how whatever you are using does it.

by joshgamble

Can anyone help me implement this with my columns that I listed?

This discussion is closed to new replies.