Q:

Convert Rows to Columns in MySQL for custom values

I have gone through a lot of similar questions(row to column conversion in mysql) and solutions provided for the same but those solutions were not working for me!
Expected Result:
Name |S1   |S2   |S3   |S4   |S5   |S6
----------------------------------------
ABC  |Pass |Fail |Fail |Pass |Pass |Fail

SQL Query:
----------

SELECT Name,
 (CASE WHEN (Semester = 'S1'  AND Result= 'Pass') THEN 'Pass' ELSE 'Fail' END) AS S1,
 (CASE WHEN (Semester = 'S2'  AND Result= 'Pass') THEN 'Pass' ELSE 'Fail' END) AS S2,
 (CASE WHEN (Semester = 'S3'  AND Result= 'Pass') THEN 'Pass' ELSE 'Fail' END) AS S3,
 (CASE WHEN (Semester = 'S4'  AND Result= 'Pass') THEN 'Pass' ELSE 'Fail' END) AS S4,
 (CASE WHEN (Semester = 'S5'  AND Result= 'Pass') THEN 'Pass' ELSE 'Fail' END) AS S5,
 (CASE WHEN (Semester = 'S6'  AND Result= 'Pass') THEN 'Pass' ELSE 'Fail' END) AS S6
FROM pivot_example
-- GROUP BY Semester

SQL Output:
Name |S1   |S2   |S3   |S4   |S5   |S6
--------------------------------------------------
ABC  |Pass |Fail |Fail |Fail |Fail |Fail
ABC  |Fail |Fail |Fail |Fail |Fail |Fail
ABC  |Fail |Fail |Fail |Fail |Fail |Fail
ABC  |Fail |Fail |Fail |Pass |Fail |Fail
ABC  |Fail |Fail |Fail |Fail |Pass |Fail
ABC  |Fail |Fail |Fail |Fail |Fail |Fail

A:

a) in order to produce one row, change:
GROUP BY Semester

into:
GROUP BY Name

b) for the pass/fail values it might be required to query, depending how the table looks alike.

