Reputation: 86
I Have a script that has a result of 3 rows only:
SELECT U.LEVEL FROM USER U
1. ADMINISTRATOR
2. STANDARD USER
3. LIMITED USER
Now what i want is to look like as a column in the result of the script. please see below:
ADMINISTRATOR | STANDARD USER | LIMITED USER
THANK YOU IN ADVANCE
Upvotes: 0
Views: 32
Reputation: 18411
I guess your question is not complete. You stated you wanted them to be the column names, but have not said what values you like. With your input, the following is a possible solution:
SELECT *
FROM (
SELECT [LEVEL]
FROM [USER]
) AS SourceTable
PIVOT(
MAX([LEVEL])
FOR [LEVEL] IN ([ADMINISTRATOR], [STANDARD USER], [LIMITED USER])
) AS PivotTable;
Upvotes: 1