Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question.

Asked: July 08, 2016 - 5:30 am UTC

Last updated: July 08, 2016 - 6:06 am UTC

Version: 11.0

Viewed 1000+ times

You Asked

How to create a table for this one.

AAA BBB CCC
RED 1 2 3
BLUE 4 5 6
GREEN 7 8 9

I tried on SQL DEVELOPER.It's gave me an error.

And converted into an out put like..

RED BLUE GREEN
AAA 1 4 7
BBB 2 5 8
CCC 3 6 9.........(For this we will use Listagg or Pivot Key word.)

SQL>SELECT LISTAGG(RED,BLUE,GREEN ', ') WITHIN GROUP (ORDER BY COLNAMES) "CONVERT"
FROM CNVT;

OR...By using Pivot_Key word.

Note:-which one is better to do a sol.

and Connor said...


AAA BBB CCC
RED 1 2 3
BLUE 4 5 6
GREEN 7 8 9

That looks to me like 3 column headings, and 4 column values in each row.

So I dont know what you are trying to achieve here.

Give us some *scripts* ... even if they dont work - at least then we can see what it is you are trying to achieve.

Is this answer out of date? If it is, please let us know via a Comment