Selecting data from multiple rows into a single row multiple columns I have a table that has columns like following. Batch number is a database design thing like row number

dm_id        type_in_id    type_student_id     amount
 36              1               1               1
 36              1               2               2
 36              1               3               3
 36              2               1               4
 36              2               2               5
 36              2               3               6
 36              3               1               7
 36              3               2               8
 36              3               3               9


I want to create a query that would return this:

dm_id  amount1 amount2 amount3 amount4 amount5 amount6 amount7 amount8 amount9
 36       1       2       3       4       5       6       7       8       9


How can I do that?

P.S. Version 5.5.56-MariaDB - MariaDB Server
SELECT dm_ID, MAX(Amount1) Amount1, MAX(Amount2) Amount2,...
FROM (
SELECT dm_id,
CASE Value WHEN 1 THEN Value ELSE NULL END AS Amount1,
CASE Value WHEN 2 THEN Value ELSE NULL END AS Amount2,
....
FROM Table
) RearrangedData


Old school pivot. It will work, but you need to know the possible values of Amount column, to use in the CASE statement...  TSQL so should be supported by mySQL.