I have a DB2 table and is the sample data.
[b]EmpID EmpName Project Name StartDate[/b]
E001 Emp1 Project1 01-01-2014
E001 Emp1 Project2 04-01-2015
E002 Emp2 Project1 05-07-2014
E003 Emp3 Project6 03-09-2014
E004 Emp4 Project3 01-09-2014
E004 Emp4 Project4 01-01-2015
E004 Emp4 Project5 09-10-2015
E001 Emp1 Project1 01-01-2014
E001 Emp1 Project2 04-01-2015
E002 Emp2 Project1 05-07-2014
E003 Emp3 Project6 03-09-2014
E004 Emp4 Project3 01-09-2014
E004 Emp4 Project4 01-01-2015
E004 Emp4 Project5 09-10-2015
Requirement: Here the condition is, The Employee can work on maximum of 3 projects at any point of time.
I want to select the data from the above the table in in the following format.
[b]EmpID EmpName Project Details[/b]
E001|Emp1|Project1|01-01-2014|Project2|04-01-2015
E002|Emp2|Project1|05-07-2014
E003|Emp3|Project6|03-09-2014
Emp4|Emp4|Project3|01-09-2014|Project4|01-01-2015|Project5|09-10-2015
E001|Emp1|Project1|01-01-2014|Project2|04-01-2015
E002|Emp2|Project1|05-07-2014
E003|Emp3|Project6|03-09-2014
Emp4|Emp4|Project3|01-09-2014|Project4|01-01-2015|Project5|09-10-2015
Can anyone suggest an SQL for this requirement ?