Pivot results

i would like to pivot the following resuts in my table . employee

Is the top row the "from" and the bottom row the "to" or vice versa?

Please post data in usable form, i.e., CREATE TABLE and INSERT, not just a picture, which we can't use to test any code we write for you.

a simple select statement

select name1,name2,name3 ,phone1, phone2 ,phone3 ,email1, email2, email3
from employee

Again, no data, no way to test, but this should at least be very close:

select name AS Managers, phone, email
from dbo.employee
cross apply ( values(name1,phone1,email1),(name2,phone2,email2),(name3,phone3,email3) ) 
    as data(name, phone, email)

you need to provide data as follows

if exists(select 1 from sys.tables where name = 'Dstyles')
	begin
		drop table Dstyles
	end;

create table dbo.Dstyles
(
ID INT IDENTITY(1,1) ,
name varchar(50),
phone varchar (50),
email varchar (50),)

insert dbo.Dstyles values ('john doe','407-512-1425', 'jdoews@Dstyles.com')
insert dbo.Dstyles values ('joe smith doe','407-512-1426', 'jsmith@Dstyles.com')
insert dbo.Dstyles values ('ken white','407-512-1475', 'kwhite@Dstyles.com')

I've reworked the data yosiasz provided. I don't normally do this because I simply don't have time to do so. We're already volunteering our own time to write poster's queries, I simply don't have time to prep test data for everyone as well.

create table dbo.employee
(
name1 varchar(80),
name2 varchar(80),
name3 varchar(80),
phone1 varchar(30),
phone2 varchar(30),
phone3 varchar(30),
email1 varchar(80),
email2 varchar(80),
email3 varchar(80)
)

insert dbo.employee ( name1, phone1, email1, name2, phone2, email2, name3, phone3, email3 )  values 
    ('john doe','407-512-1425', 'jdoews@Dstyles.com',
     'joe smith doe','407-512-1426', 'jsmith@Dstyles.com',
     'ken white','407-512-1475', 'kwhite@Dstyles.com')

select name AS Managers, phone, email
from dbo.employee
cross apply ( values(name1,phone1,email1),(name2,phone2,email2),(name3,phone3,email3) ) 
    as data(name, phone, email)
1 Like

thx i reworked the above and got what i needed