Slavisha
Slavisha

Reputation: 219

SQL Server - Pivot data

I am trying to figure out how to transpose data from last two column in SQL table from this layout:

enter image description here

into lay out where im going to have one line with last two column to be "fw" and "bw" with counts values underneath as on the layout below:

enter image description here

I understand that i have to use Pivot and i have been trying to follow few tutorials and few post here on stack-overflow but i cant seem to make it work. Any hint or help would be much appreciated.

Upvotes: 1

Views: 34

Answers (1)

Fahmi
Fahmi

Reputation: 37473

You can try below

select * from tablename
pivot
(
  sum(counts) for label in ([fw],[bw])
) as pv

Upvotes: 2

Related Questions