How can I pivot result of SQL query

时间:2017-06-15 09:50:42

标签: mysql sql

I Have this result in for my SQL query

enter image description here

and I want to convert it like this

enter image description here

1 个答案:

答案 0 :(得分:2)

You could use (a fake) aggregation function and group by

select type_revenue
  , max(case when location_name ='30juin' then amount else 0 end) 30Jui
  , max(case when location_name ='Bandal' then amount else 0 end) Bandal
from my_tbale 
group by type_revenue