select product_id,
sum(if(store='store1',price,null)) as store1,
sum(if(store='store2',price,null)) as store2,
sum(if(store='store3',price,null)) as store3
from Product
group by product_id
行变列(union all)
select product_id,'store1' as store,store1 price from Product
where store1 is not null
union all
select product_id,'store2' as store,store2 price from Product
where store2 is not null
union all
select product_id,'store3' as store,store3 price from Product
where store3 is not null