Hi @Jose Ramirez ,
Welcome to Microsoft Q&A!
Please refer below and check whether it is working.
select a.RateAirlineID,
max(case when b.RateSlab = 'Min' then b.NetRate end) as [MinNR],
max(case when b.RateSlab = 'Min' then b.SellingRate end) as [MinSR],
max(case when b.RateSlab = '-45' then b.NetRate end) as [-45NR],
max(case when b.RateSlab = '-45' then b.SellingRate end) as [-45SR],
max(case when b.RateSlab = '+45' then b.NetRate end) as [+45NR],
max(case when b.RateSlab = '+45' then b.SellingRate end) as [+45SR],
max(case when b.RateSlab = '+100' then b.NetRate end) as [+100NR],
max(case when b.RateSlab = '+100' then b.SellingRate end) as [+100SR],
max(case when b.RateSlab = '+300' then b.NetRate end) as [+300NR],
max(case when b.RateSlab = '+300' then b.SellingRate end) as [+300SR],
max(case when b.RateSlab = '+500' then b.NetRate end) as [+500NR],
max(case when b.RateSlab = '+500' then b.SellingRate end) as [+500SR],
max(case when b.RateSlab = '+1000' then b.NetRate end) as [+1000NR],
max(case when b.RateSlab = '+1000' then b.SellingRate end) as [+1000SR],
max(case when b.RateSlab not in ('Min','-45','+45','+100','+300','+500','+1000') then b.RateSlab end) as [Pivot],
max(case when b.RateSlab not in ('Min','-45','+45','+100','+300','+500','+1000') then b.NetRate end) as [PivotNR],
max(case when b.RateSlab not in ('Min','-45','+45','+100','+300','+500','+1000') then b.SellingRate end) as [PivotSR]
from RateAirlineTable a
left join RateAirlineslabTable b
on a.RateAirlineID=b.RateAirlineid
group by a.RateAirlineID
Output:
Best regards,
Melissa
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.