Monday 10 February 2014

Convert Column to Row using UNPIVOT

When we run the following query, 
select character1,character2 from qa_results

the result will be,

character1 character2
10              12

If we want to change the columns to rows, then UNPIVOT can be used.

Example:

select plan_id,valu,qty from qa_results
unpivot(valu for qty in (character1,character2)))
where plan_id = 7100
            

The output of the above query will be,

Valu Qty

10     CHARACTER1
12     CHARACTER2

1 comment:

  1. Casino Review - The King of Dealer
    This casino is a real online gambling and kirill-kondrashin the site has a good reputation for gaming quality. On top of that, while the live gaming experience goes 우리카지노

    ReplyDelete