Getting max() for a column

I have scenario,
have table with 2 columns, process_id and Job_name
and i have 10 records with same job names
i need to get latest record, that is like select max(process_id) from Table1
process_id is sequentially generated using sequence
or select process_id, Job_name from table1 a where process_id = (select max(process_id) from table1 b where a.job_name = b.job_name)
output should be only 1 record.
Can anyone help me on this, on how to do in talend,
i tried using taggregator component but it is giving multiple records..
Vivek Jayapalan
One Star mpa
One Star

Re: Getting max() for a column

Ok so first make a context variable in ur repository and add it to your project.
then add following components after your input.
tMSSqlInput (or another input depending on how u get ur data) ==> tAggregateRow ==> tJavaRow

tMSSqlInput: ur table input in a query. So no max() yet.
tAggregateRow: In operations add a column. Choose ur Process_id as input column. and choose max as the function.
tJavaRow: Assign the value from the input to your context variable.
Example: context.MaxProcess_id= input_row.process_id;
MaxProcess_id => is ur context variable made.
Good luck.