Hi

I have database in structure like below

Newspaper State1 state2 state3 state4

ABC 1000 5684 5687 246
DEF 879 2547 2578 2357

But I need to the structure like below

How can i change this

Newspaper State copies

ABC State1 1000
ABC State2 5684
ABC State3 5687
ABC State4 246
DEF State1 879
DEF State2 2547
DEF State3 2578
DEF State4 2357

Pls help me

Maideen

Re: how to convert pivot data into unpivot data 80 80

here is the code

SELECT [NewsPaper]
      ,[State],[Copies]
FROM 
   (SELECT [NewsPaper]
      ,[State1]
      ,[State2]
      ,[State3]
      ,[State4]
   FROM [Test].[dbo].[News]) p
UNPIVOT
   (Copies FOR State IN 
      (State1,State2,State3,State4)
)AS unpvt;
GO
Re: how to convert pivot data into unpivot data 80 80

Step 1 Select the data and turn it into a table
Step 2 Select Power Query –> From Table to suck it in to Power Query
Step 3 Un-pivot it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.