Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Unpivot Example
--Sql Server 2014 Express Edition --Batches are separated by 'go' declare @temp table (vendor_id int, emp1 int, emp2 int, emp3 int, emp4 int, emp5 int); insert into @temp values (1,4,3,5,4,4); insert into @temp values (2,4,1,5,5,5); insert into @temp values (3,4,3,5,4,4); insert into @temp values (4,4,2,5,5,4); insert into @temp values (5,5,1,5,5,5); select * from @temp select vendor_id as VendorID, Employee, Orders from (select vendor_id,emp1,emp2,emp3,emp4,emp5 from @temp) as p unpivot( Orders for Employee in (emp1,emp2,emp3,emp4,emp5) ) as unpvt order by unpvt.Employee asc , unpvt.vendor_id asc
run
|
edit
|
history
|
help
0
Names
Hack_this
Changing URLs in a SQL table
Marco - Arvind
Task2_Final
Cinema latinoamericano
MLK Date
db
Dbms_20181cse0068
SQL Server - Multiple Holidays Model