Join the table to itself, with one side of the join for brand and the other side for the competitor.
select
a.Store_Id,
a.Category,
b.Category Comp_Brand,
a.Quantity,
b.Quantity Competitor
from mytable a
left join mytable b on b.Store_Id = a.Store_Id
and b.Category = a.Category || '_Competitor'
where a.Category not like '%_Competitor'
order by a.Store_Id, a.Category
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…