#1 2011-01-04 16:12:05

vivekjayapalan
Member
Company: Mindtree Ltd
Registered: 2010-11-25
Posts: 38
Website

Getting max() for a column

Hi

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..

Thanks,
Vivek Jayapalan

Offline

#2 2011-01-04 16:43:49

mpa
Member
Company: Thinking Solutions
Registered: 2010-12-17
Posts: 257
Website

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.

Last edited by mpa (2011-01-04 16:44:38)

Offline

Board footer

Powered by FluxBB