RadhaKrishnaKiJaya
asked on
Convert columns to rows in SQL
Hello Experts,
I have a column based table of million of rows. I am trying to convert the columns to rows for better readability. See the attachment for details. Please let me know how to get the output. Thank you very much in advance.
Thank you!
Pivot.png
I have a column based table of million of rows. I am trying to convert the columns to rows for better readability. See the attachment for details. Please let me know how to get the output. Thank you very much in advance.
Thank you!
Pivot.png
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Kindly check whether the below query returns values and if so, then you should get proper records for the first query provided..
SELECT CID, FNAME, FV
FROM table1
JOIN table2 on table1.FID = table2.FID
ASKER
Raja, Thank you very much. Your code is working as expected. There was some error in my typing. Thank you again.
Welcome, no issues..
ASKER
Raju,
Can I use the fields [FN-1], [FN-2], [FN-3] ect. with where clause to filter some rows? If so, how? When I use it,, I get "Invalid column name FN-1" error.
Thank you a lot.
Can I use the fields [FN-1], [FN-2], [FN-3] ect. with where clause to filter some rows? If so, how? When I use it,, I get "Invalid column name FN-1" error.
Thank you a lot.
Yes, we can use these columns in WHERE clause.
Since you have - inside, just use [FN-1] which might help..
Since you have - inside, just use [FN-1] which might help..
ASKER
I already tried that and got "Invalid column name FN-1" error. Any different way to use it?
Can you provide your complete query to help out with..
ASKER
CID 1 2 3
10001 null null null
More over the FN-1, FN-2, FN-3 are the descriptions. But, I received just the numbers.