I have two tables:
Departments --< Employees
Department table has data such as:
id, Name
1, Marketing
2, Sales
Employees table has data such as:
id, Name, DepartmentId, RatePerDay
1, Alex,1, 40
2, Bob,1, 30
3, Calvin,1, 40
4, Dal,1, 30
I want to get two data sets back as follows for each department:
DepartmentName, Employee1,Employee12,Employee13,Employee14
Marketing, Alex, Bob, Calvin, Dal
DepartmentName, RatePerDay1, RatePerDay2, RatePerDay3, RatePerDay4
Marketing, 40,30,40,30
I have to write a MS SQL 2008 Stored procedure which achieves this result?
Any help is appreciated
rows to columns tsql