My Table looks like the following:

```
      TableA

ID    |SEQ |CODE
======|====|=========
Item1 |1   |A
Item1 |2   |B
Item2 |1   |A
Item2 |2   |B
Item2 |3   |C
Item3 |1   |B
Item4 |1   |C

```

Each `ID` goes up 1 in `SEQ` for each `CODE` it has applied, depending on the order in which it was applied. I am trying to add more data to this table for a new code, and want to add it for a certain set of items from a second table, as the most recent sequence number for that item. What I have so far

```
Insert Into TableA
Values(TableB.ID, 
(Case when TableA.SEQ = '1' and Count(TableA.ID) = 1 then '2'),
'E')
From TableB
Join TableA on TableA.ID = TableB.ID
Where TableB.E_ADDED = 'Y' and
TableA.ID = TableB.ID

```

This code obviously doesn't work, and I can't think of a word or phrase to describe what I'm trying to do to search it, so I figured I would ask.