cancel
Showing results for 
Search instead for 
Did you mean: 

How can I change my query results to column names

former_member555662
Discoverer
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

gaurav_bali
Active Participant

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.

https://technet.microsoft.com/en-us/library/ms177410(v=sql.105).aspx

http://stackoverflow.com/questions/15931607/convert-rows-to-columns-using-pivot-in-sql-server

lbreddemann
Active Contributor
0 Kudos

This question is about SAP HANA, not SQL Server. The pivot function you refer to is a non-standard feature provided by SQL Server and not available on SAP HANA.

gaurav_bali
Active Participant
0 Kudos

Hi Lars

The tag on the question is for SQL and SAP Business One.

lbreddemann
Active Contributor
0 Kudos

Yes, and the primary tag (the one above the question title) is "SAP HANA". Yes, I agree, it's not clever UI design to spread the different tags around...

gaurav_bali
Active Participant
0 Kudos

Missed that one thanks for pointing out

Answers (1)

Answers (1)

gaurav_bali
Active Participant
0 Kudos

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.

https://blogs.sap.com/2013/11/11/how-to-dynamic-transposition-in-hana/

https://blogs.sap.com/2014/01/02/table-transpose-in-sap-hana-modeling/