0

I am looking for mysql - sql query to generate simple report as below: enter image description here

Data source, table

CatName Product               Price
Rice    5Kg Mbeya Rice         2000
Oil     12 ltrs Sunflower oil  2000
Rice    5Kg Mbeya Rice         2000
Oil     12 ltrs Sunflower oil  2000
Rice    5Kg Mbeya Rice         2000
Eggs    30 Yellow Yolk Eggs    2000
Oil     12 ltrs Sunflower oil  2000
Rice    5Kg Mbeya Rice         2000
Oil     12 ltrs Sunflower oil  2000
Rice    5Kg Mbeya Rice         2000
Eggs    30 YellowYolk Eggs     2000
Oil     12 ltrs Sunflower oil  2000
Oil     12 ltrs Sunflower oil  2000
Oil     12 ltrs Sunflower oil  2000

Assistance will be appreciated.

Strawberry
  • 33,750
  • 13
  • 40
  • 57
fraka
  • 1
  • 2
  • 4
    Most people here want formatted text, not images. (Or, even worse, links to images.) – jarlh Oct 30 '17 at 12:49
  • 1
    Basic pivot... `SELECT CatName as categories, MAX(CASE WHEN product = '5Kg Mbeya Rice' THEN price ELSE '-' END) as '5Kg Mbeya Rice', [more MAX cases] FROM [table] GROUP BY categories ORDER BY categories ASC`.... Making it dynamic https://stackoverflow.com/search?q=dynamic+pivot+mysql – Raymond Nijland Oct 30 '17 at 12:58
  • Seriously consider handling issues of data display in application code. – Strawberry Oct 30 '17 at 14:10

0 Answers0