Reputation: 407
I have a table with format-
Name | Value A | Value B | Comment
ABC 100 50 Test1
DEF 200 60 Test2
I want the result in the format
Name | AorB | Values | Comment
ABC Value A 100 Test1
ABC Value B 50 Test1
DEF Value A 200 Test2
DEF ValueB 60 Test2
Upvotes: 0
Views: 67
Reputation: 125
You can use UNION
to achieve that:
select Name, 'Value A' as AorB, valueA as [Values], Comment
from Table1 t1
union
select Name, 'Value B' as AorB, valueB as [Values], Comment
from Table1 t1
Working sample: http://www.sqlfiddle.com/#!3/70f05/2
Upvotes: 2