Hello Team,
I want query which will convert metadata from rows structure to column structure.
Actually we have template with multi-level group fields ( see image Group wise query.png) and we need everything in column along with single column like ( table format.png).
We are using below query but it won't be work and giving wrong output.; as for multi-level group some of the values were null but still it dispalyed.
I am using below query.
select distinct * from (
select toc.tocid, LRO_Attorney.pos,LRO_Attorney.pos2, toc.name AS ReportName, LRO_Attorney.str_val as LRO_Attorney, Rulemaking_Stage.str_val as [Rulemaking stage], RIN.str_val as [RIN],Bureau.str_val as [Bureau],Stage_Status.str_val as [Stage_Status],isnull(Phase_of_Review.str_val,'') as [Phase_of_Review]
from toc inner join propval as LRO_Attorney on toc.tocid = LRO_Attorney.tocid and LRO_Attorney.prop_id = 1515
inner join propval as Rulemaking_Stage on toc.tocid = Rulemaking_Stage.tocid and Rulemaking_Stage.prop_id = 1269
inner join propval as RIN on toc.tocid = RIN.tocid and RIN.prop_id = 1267
inner join propval as Bureau on toc.tocid = Bureau.tocid and Bureau.prop_id = 929
inner join propval as Stage_Status on toc.tocid = Stage_Status.tocid and Stage_Status.prop_id = 1276
inner join propval as Phase_of_Review on toc.tocid = Phase_of_Review.tocid and Phase_of_Review.prop_id = 2442
where etype = -2 and pset_id = 500
) as p where p.RIN = '0692-XA001'