troubleshooting Question

How to pivot one column

Avatar of James Murrell
James MurrellFlag for United Kingdom of Great Britain and Northern Ireland asked on
Microsoft SQL ServerSQL
6 Comments2 Solutions308 ViewsLast Modified:
Hi, gone brain dead again, here is ideal

[staffname] [area]
staffA          area1
staffA          area2
staffA          area3

what i need is

[staffname] [area] [area] [area]
staffA          area1 area2 area3

here is full code so far
SELECT     staffnames.title, staffnames.fname, staffnames.mname, staffnames.sname,,,, staffnames.payroll_report, staffnames.external_payroll_ref, staffnames.payroll_export, 
                      staff_extra.LN, staff_extra.DOB, staff_extra.LE, staff_extra.NK, staff_extra.NKC, staff_extra.PayrollRef, staff_extra.CCTV, staff_extra.CCTV2, staff_extra.CP, 
                      staff_extra.CP2,  areas.area
FROM         areas INNER JOIN
                      staff_area ON areas.area_id = staff_area.area_id RIGHT OUTER JOIN
                      staffnames INNER JOIN
                      staff_extra ON staffnames.staff_id = staff_extra.staff_id ON staff_area.staff_id = staffnames.staff_id
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 6 Comments.
Join the Community
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 2 Answers and 6 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