We help IT Professionals succeed at work.
Get Started

Pivot table for MS SQL

Errol Farro
Errol Farro asked
on
71 Views
Last Modified: 2020-01-15
I have a table as per the below

I have a table as per the below and would like to create a pivot tabe using MS SQL. Note - there are about 30 GL numbers. The attached gives a better illustration of the below

Any help is appreciated.

Field             Description
mfMpid            Customer Number
mpGlno            Gl number
mpAmount      Amount booked on G/L


Example of content of file
==========================

mfMpid      mpGlno      mpAmount
1      5      200
1      7      300
1      3      700
1      5      800
2      2      300
2      4      600
3      8      100
3      9      200
3      1      400


Expected result
===============

GL            1      2      3      4      5      7      8      9
1                  700            1000      300            
2            300            600                        
3      400                                    100      200
Capture.JPG
Comment
Watch Question
Senior Developer
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE