We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Simply i wrote this code in SQL Server and its working fine:
select Doctor,Professor,Singer,Actor from
(select Name,Occupation ,row_number() over(partition by Occupation order by Name) rn from Occupations) as source
pivot
( max(name) for Occupation in (Doctor,Professor,Singer,Actor)
) as PVT;
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Occupations
You are viewing a single comment's thread. Return to all comments →
Simply i wrote this code in SQL Server and its working fine:
select Doctor,Professor,Singer,Actor from (select Name,Occupation ,row_number() over(partition by Occupation order by Name) rn from Occupations) as source pivot ( max(name) for Occupation in (Doctor,Professor,Singer,Actor) ) as PVT;