Let’s talk about the transformation of table data from rows to columns. Such transformation is called pivoting tables. Often, the result of the pivot is a summary table in which statistical data are presented in the form suitable or required for a report.
Besides, such data transformation can be useful if a database is not normalized and the information is stored therein in a non-optimal form. So, when reorganizing the database and transferring data to new tables or generating a required data representation, data pivot can be helpful, i.e. moving values from rows to resulting columns.
Here you can see the transformation from rows to columns — https://goo.gl/VTfQsN.
Such a result can be easily achieved. Find more examples of pivot tables with the code samples here — http://codingsight.com/pivot-tables-in-mysql/.
Thank you for your time.