No hay un comando PIVOT en MySQL, pero hay soluciones:Conceptos básicos de la tabla dinámica:filas a columnas... , Tablas dinámicas de MySQL (transformar filas en columnas) .
Para su caso, podría usar algo como esto -
SELECT AppNo,
MAX(IF(code = 1, Location, NULL)) Location,
MAX(IF(code = 1, Department, NULL)) Department,
1 Code1,
MAX(IF(code = 2, Location, NULL)) Location,
MAX(IF(code = 2, Department, NULL)) Department,
2 Code2,
MAX(IF(code = 3, Location, NULL)) Location,
MAX(IF(code = 3, Department, NULL)) Department,
3 Code3,
MAX(IF(code = 4, Location, NULL)) Location,
MAX(IF(code = 4, Department, NULL)) Department,
4 Code4,
MAX(IF(code = 5, Location, NULL)) Location,
MAX(IF(code = 5, Department, NULL)) Department,
5 Code5
FROM <table name>
GROUP BY AppNo
PD Puede ejecutar esta consulta desde la rutina almacenada.