I apologize if the question is a duplicate but I have some requirement which is getting on my nerves. And after many attempts I am unable to solve it. The requirement is I have a table which has data as follows:
CHANGE_NUMBER ITEM_NUMBER REV BOM_ITEM FIND_NUMBER QUANTITY
MD04086 710851-1 B 230248-0 0 9
MD04086 710851-1 B 230289-0 0 4
MD04086 710851-1 B 230292-0 0 1
MD04086 710851-1 B 230298-0 0 2
What I want to do with this data is to make it in the following format:
Column_name Column_Value
CHANGE_NUMBER MD04086
ITEM_NUMBER 710851-1
REV B
BOM_ITEM 230248-0
FIND_NUMBER 0
QUANTITY 9
CHANGE_NUMBER MD04086
ITEM_NUMBER 710851-1
REV B
BOM_ITEM 230289-0
FIND_NUMBER 0
QUANTITY 4
So far I have used the following query but it does not provide me what I am trying to achieve
with q1 as
(select 'itemRev' as column_name,[CHANGE_NUMBER] as column_value from generalassemblies_data_final
union all
select 'itemNumber' as column_name,[ITEM_NUMBER] as column_value from generalassemblies_data_final
union all
select 'REV' as column_name,[REV] as column_value from generalassemblies_data_final
union all
select 'BOM_ITEM' as column_name,[BOM_ITEM] as column_value from generalassemblies_data_final
union all
select 'findNum' as column_name,[FIND_NUMBER] as column_value from generalassemblies_data_final
union all
select 'qty' as column_name,[QUANTITY] as column_value from generalassemblies_data_final
)
select *
from q1;
Can anybody please help me out here.