Forum Discussion
Listing Values, Columns Axis
Hi, I have a large number of columns in SQL Server (150) that have values. Let's say the values are green, blue, red. My goal is to display all of the columns with a value of green from top to bottom vs. a table that wants to add the columns left to right.
Is there a way to do this?
7 Replies
- lbendlinSuper User
Columns don't have values. They have row numbers (or indexes) which then point to cells that have values.
To swap columns and rows you can use Pivot/unpivot transforms.
You would need to run a custom function that identifies the names of the columns containing cellse with the value "green".
Then you would do a SelectColumns against that list
Then you would do the pivoting thing to swap rows and columns.
Now the question is - how many rows does your table have? This might be fine for 20 rows, but will certainly not work for millions of rows.
- ez1138Frequent Visitor
Thanks for the reply. I have a few hundred columns and only a few hundred rows. I have no clue, yet, on how to do what you mentioned although it moves the ball forward and I will research it. Thanks!
- ez1138Frequent Visitor
For your proposed solution, do you have any direction to perform/create the function?
- lbendlinSuper User
provide some sample data and the expected result