You can also try using the dedicated PIVOT function if it is supported by the SQL product that you are using. For example, the following will work in SQL Server 2005+ :
SELECT * FROM ( SELECT DISTINCT Project_Type, 'true' AS flag, OS_Platform FROM MY_TABLE ) s PIVOT ( MAX(flag) FOR OS_Platform IN ( Linux, Windows, Solaris ) ) p ;
Oracle Database is another product that supports PIVOT, although I'm not sure which version it was first introduced in. You could execute the above query in Oracle after including each column in the PIVOT IN list in single quotes, for example:
... IN ( 'Linux', 'Windows', 'Solaris' ) ...
source share