0

How do i make this into wide transposed format?

  Id         Food   price      Date            
  1          K      200        2017-01-02
  2          L      150        2017-01-02
  3          M      110        2017-01-02

without using pivot and without hardcoding it?

I'm not able to figure out how to not hardcode this. Hardcoding would be:

select Date,
max(if(Food='K', 200, null)) as FoodA,
max(if(Food='L', 150, null)) as FoodB,
max(if(Food='M', 110, null)) as FoodC
from table
group by Date
Veijo
  • 264
  • 2
  • 9
as26
  • 81
  • 8

0 Answers0