I have rows called studentname and college. How can I convert this rows into columns with SQL?
1 Answer
I suppose you are trying a transpose operation..Let us consider this table for E.g:
TYPE DESCRIPTION
- AAKASH
- DJSCOE
To convert it to columns you can use this query which uses TYPE column:
SELECT * FROM
(
SELECT TYPE, DESCRIPTION
FROM TRANSPOSE
)
PIVOT (
COUNT(TYPE)
FOR TYPE in ('1','2')
);
Note: PIVOT is supported only from Oracle 11g onwards.
Concept: https://www.techonthenet.com/oracle/pivot.php
Enjoy..