Thursday, 15 August 2013

Using SQL pivot in case with only one duplicated data field -


I have a table that looks something like this.

  owner's owner_mail customer friend 1 email 1 customer 1 friend 1 email 1 customer 2 friend 1 email 1 customer 3 friend 3 email 2 customer4 dude2 email2 customer 5   < P> etc ...  

I am looking for the following

  owner / email client customer customer 2 customer 3 etc   < P> Using PUTICE examples on this site, I am starting to see that I will need it by some other group and I do not have this In is using the correct solution of smoke here? I use the following example from the following:  IN ([name1] [name2] as PIVOT (maximum [subscriber])  
  SELECT * (SELECT [owner] , [Owner_email], [from tTableName] [customer])] [name 3] [name 4] [name 5]) as private   

thanks

To do this, you type row_number () in your internal query I name1 I am using row_number with name to create, name2 , etc. Then when you will apply the PIVOT function you will return the customer to different columns for each owner: