I have a table that looks like this
and I want it like below, how should I do it in sql? If I use GROUP BY
I am unable to use max, min functions on strings
I have a table that looks like this
and I want it like below, how should I do it in sql? If I use GROUP BY
I am unable to use max, min functions on strings
SELECT *
FROM TableName t
PIVOT (MAX(Name)
FOR EMPLOYEETYPE
IN (ENGINEER, MANAGER, TECHNICIAN)
)p
Since you have mentioned, you have joins and some other stuff in your actual query all you need to do is
SELECT * FROM
(
/*
Your Query here
just make sure it is only returning the columns shown in your question
*/
)t
PIVOT (MAX(Name)
FOR EMPLOYEETYPE
IN (ENGINEER, MANAGER, TECHNICIAN)
)p