If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Put value in multiple column to 1 column and multiple rows

Started by peewan, 19 Mar 2021 11:34:00 AM

Previous topic - Next topic

peewan

I have code values in 5 diffrence column, and I want to put them in one column (mutiple row with same ID).
How could I do this?

ID        Column1    column2  column3
A12B    Code1        Code2     Code3

turn to:
ID      Column
A12B  Code1
A12B  Code2
A12b  Code3

adam_mc

A crude solution would be to create 5 queries and then union them together - I would only do this if the number of code columns is known to be fixed and will not change.
Also, this assumes that each of the code columns are the same data type.
Each query would have the ID and one of the code columns as follows:

Query1:
ID, C1

Query2:
ID, C2

etc..

Then, union the 5 queries together and the resulting query will have your required output.
You will need to determine based on your use case if you need union or union all functionality.

Hope this helps,
Adam.

peewan