views:

13

answers:

0

Pivot: Assume that you have table A that contains data regarding tips earned for each employee in the following format: A(empid, Mon_tips, Tues_tips, Wed_tips, Thu_tips, Fri_tips). Write a SQL query that will convert the data from table A into table B with the following format: B(empid, Day, tips) where the column Day can take the values (Mon, Tue, Wed, Thu, Fri).

create table A( empid int, Mon_tips int, Tue_tips int, Wed_tips int, Thu_tips int, Fri_tips int);
insert into A values (1, 10,20,30,20,10);
insert into A values (2, 10,20,30,40,50);