select
distinct state,sector,
pt.RSGHDPE as [PPC],pt.OPC43HDPE as [OPC43],
pt.OPC53HDPE as [OPC53],pt.RSFHDPE as [RSF]
from RMCL_DESPSUM_This_year as t
pivot (min(t.factory) for t.item_name in( RSGHDPE,OPC53HDPE,OPC43HDPE,RSFHDPE)) as pt
where inv_Date between'2017-04-01 00:00:00.000'and getdate()
order by state
I have given one value from item code which is RSGHDPE , but i have 6 items which starts with RSG likewise for other itemnames also
what i am looking for is below one or any other method
pivot (min(t.factory) for t.item_name like( 'RSG%','OPC53%','OPC43%','RSF%')) as pt