Input :
| Student Name | Subject Name | Marks |
| Sam | Maths | 100 |
| Tom | Maths | 80 |
| Sam | Physical Science | 80 |
| John | Maths | 75 |
| Sam | Life Science | 70 |
| John | Life Science | 100 |
| John | Physical Science | 85 |
| Tom | Life Science | 100 |
| Tom | Physical Science | 85 |
Output :
| Student Name | Maths | Life Science | Physical Science |
| Sam | 100 | 70 | 80 |
| John | 75 | 100 | 85 |
| Tom | 80 | 100 | 85 |
Answer :
Here the transformation which we have to use is Sorter and Aggregator .
Lets see the approach :
1) The Input from the Source Qualifier is sent into the Sorter transformation , And Sorted based on Student name and Subject.
The following output is obtained
| Student Name | Subject Name | Marks |
| Sam | Maths | 100 |
| Sam | Life Science | 70 |
| Sam | Physical Science | 80 |
| John | Maths | 75 |
| John | Life Science | 100 |
| John | Physical Science | 85 |
| Tom | Maths | 80 |
| Tom | Life Science | 100 |
| Tom | Physical Science | 85 |
2) The output from Sorter transformation is sent into the aggregator transformation and Group by Student name is selected . As we need the final output grouped with student name.
And also in the aggregator transformation three columns are created like
1) Maths --- with formula -- Max(Marks, Subject = 'Maths')
2) Life Science --- with formula -- Max(Marks, Subject = 'Life Science')
3) Physical Science --- with formula -- Max(Marks, Subject = 'Physical Science')
3) Now Student name and Maths , Life Science , Physical Science are connected to the target.
The output obtained is as follows :
| Student Name | Maths | Life Science | Physical Science |
| Sam | 100 | 70 | 80 |
| John | 75 | 100 | 85 |
| Tom | 80 | 100 | 85 |