0

I have rows called studentname and college. How can I convert this rows into columns with SQL?

1
  • 3
    Please edit & add a tag for the specific DB you are using. Commented Jul 10, 2018 at 13:08

1 Answer 1

1

I suppose you are trying a transpose operation..Let us consider this table for E.g:

TYPE DESCRIPTION

  1. AAKASH
  2. 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..

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.