Link to home
Start Free TrialLog in
Avatar of emi_sastra
emi_sastra

asked on

Arrange rows to colums

Hi All,

I have below data :

1	AUDI
55	AUDI
109	ALFA ROMEO
127	BMW
181	BMW

Open in new window


I want to convert it into :

1        54  AUDI
55     108 AUDI
109   126 ALFA ROMEO
127   180 BMW
181   181 BMW

How could I do it ?

Thank you.
Avatar of Timothy Bryant
Timothy Bryant
Flag of United States of America image

What version of MS SQL are you using? The PIVOT function would work if I am understanding what you are wanting to do.

https://www.databasejournal.com/features/mssql/converting-rows-to-columns-pivot-and-columns-to-rows-unpivot-in-sql-server.html
Avatar of emi_sastra
emi_sastra

ASKER

Hi Timothy,

I use sql 2008.

Please provide solution.

Thank you.
What you need is a running total with a bit of twist (minus 1)
Hi John,

Still don't get the idea ?

Thank you.
ASKER CERTIFIED SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you all.