Skip to Content

How can I change my query results to column names

Hi There,

I have below table need to change as 2nd table.

Item No. Item Description BP Code BP Catalog Number 12960 SANDRA-WP-BLUE/CHOCOLATE-SINGLE--54"x84" C10058 12960 SANDRA-WP-BLUE/CHOCOLATE-SINGLE--54"x84" C10068 12960 SANDRA-WP-BLUE/CHOCOLATE-SINGLE--54"x84" C10069 8.583E+11 12960 SANDRA-WP-BLUE/CHOCOLATE-SINGLE--54"x84" C10076 12960 SANDRA-WP-BLUE/CHOCOLATE-SINGLE--54"x84" C10084 8.583E+11 12960 SANDRA-WP-BLUE/CHOCOLATE-SINGLE--54"x84" C10091 12960 SANDRA-WP-BLUE/CHOCOLATE-SINGLE--54"x84" C10113 14285 WESLEY-CS-INDIGO/GRAY-4 PC -CK-102"X92" C10058 14285 WESLEY-CS-INDIGO/GRAY-4 PC -CK-102"X92" C10068 14285 WESLEY-CS-INDIGO/GRAY-4 PC -CK-102"X92" C10084 8.583E+11 14421 WESLEY-V-INDIGO/GRAY-SINGLE--18"X84" C10058 14421 WESLEY-V-INDIGO/GRAY-SINGLE--18"X84" C10076

I need them to be like this.

Row Labels C10011 C10022 C10030 C10035 C10038 C10050 16T000184 848742045152 0 8.48742E+11 16T000185 848742045169 0 8.48742E+11 16T000302 848742047453 0 8.48742E+11 16T000331 848742047736 0 8.48742E+11 16T000415 848742048467 0 8.48742E+11 16T000548 848742049815 0 8.48742E+11 16T000549 848742049822 0 8.48742E+11 16T000553 848742050019 0 8.48742E+11 16T000555 0 8.48742E+11 16T000557 0 8.48742E+11 16T000562 0 8.48742E+11
Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    Posted on Feb 16, 2017 at 04:20 AM

    HI Azra

    To convert rows to column you can use following techniques.

    1) If the number of rows is fixed. You can use SubQuery as Column.

    2) Use Pivot tables here are few links which might help you.

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 20, 2017 at 04:48 AM

    Hi Azra

    In case it is HANA DB and not sql as Mr. Lars points out you might like to check the below links which explains how to transpose a table. These are the links I found while browsing though we do not use HANA and our knowledge in the field is currently limited.

    Add comment
    10|10000 characters needed characters exceeded