Link to home
Start Free TrialLog in
Avatar of James Murrell
James MurrellFlag for United Kingdom of Great Britain and Northern Ireland

asked on

How to pivot one column

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.mobile, staffnames.email, staffnames.website, 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

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of James Murrell

ASKER

WOW always good to learn.. yes i need as  (per staff) into 1 value, comma-separated

but still unsure how to do...

lucky in this example it will be only 3,
I have posted the url where you can learn how to build your SQL accordingly.
if you want comma seperated try this

select [staffname],[area] from tablename groupby staffname
Yes thanks Angel Eyes..... i been reading and reading it but i am confused, sorry..... but i am trying


James
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial