I have select statement result as below: When I pivot it I have result in different order
Name ID
ACB123456 FF1234
ACB123456 FF1234
ACB123456 FF1234
ACB123456 FF1234
ACB123456 FF1234
ACB123456 FF1234
ACB123456 GG5642
ACB123456 FF10096
ACB123456 GG03884
ACB123456 FF15738
I want to see data in the same order as shown above
Name id1 id2 id3 id4 id5
ACB123456 FF1234 GG5642 FF10096 GG03884 FF15738
SQL I tired for it
select distinct id,name, RowN = Row_Number() over (partition by id order by name
) from table1