Use max value from one column in one table as a starting value for autoincrement in another table

Hi,

I have two tables, which both have an ‘Item ID’ column. I’d like to use Knime to find the maximum value in the Item ID column of table 1, and then fill in Item IDs column in table 2 with ascending numbers starting from this value.

So for e.g. if the Item IDs in table 1 were 1, 2, 5, 6, 7, 11, 14, then the max value in that column would be 14. And the Item IDs in table 2 would then be 15, 16, 17, 18, 19 … etc.

I’ve used the autoincrement node to set the Item IDs in table 2 as ascending values, but I can’t figure out how to extract the max value from Table 1.

One idea I thought of for doing it would be to sort the Item ID column in Table 1 in ascending order, then join the two tables together with Table 1 at the top. And then somehow autoincrement only the blank cells. But again I don’t know how to do it!

Thanks in advance if you can help - I’m new to this and really stuck!

hi @ucaee
i’m not sure if my approach here met your expectation,
image
KNIME_id-MM.knwf (93.6 KB)
rgds

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.