on 02-16-2017 12:05 AM
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" C10076I 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+11HI 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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.