-2

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

Steve Dilu
  • 35
  • 6
  • Try to see: https://stackoverflow.com/questions/7674786/mysql-pivot-table (this is first result using Google search with words: pivot mysql) – etsa Jun 15 '17 at 09:53

1 Answers1

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
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107