Converting Columns into Rows in Teradata

To convert columns into rows, UNION ALL operator can be used. Unlike Oracle, Teradata does not support UNPIVOT function. However the same functionality can be achieved using the following syntax.

Sample data : student_marks
idnamemathsphysics
1Ren8065
2Mark9873

Query
SELECT id,maths,'M' FROM student_marks
UNION ALL
SELECT id,physics,'P' FROM student_marks

Output
idmarkssubject
180M
298M
165P
273P