Link to home
Start Free TrialLog in
Avatar of himabindu_nvn
himabindu_nvn

asked on

SQL Query

I have a table as below

Material   SeqNum   Controlkey
22             1                  x
22             2                  x
22             3                  x
22             4                  x
24             1                  x
24             2                  x

I have to update controlkey='y' for the max(seqno) for each material. I came up with the query

update Table_3
set ckey='ybp3'
from Table_3
where seqno=(select MAX(seqno)
from Table_3
group by Material)

But this is giving me two values in subquery . Here in the above query I need to update table as

Material   SeqNum   Controlkey
22             1                  x
22             2                  x
22             3                  x
22             4                  y
24             1                  x
24             2                  y


Thanks !
ASKER CERTIFIED SOLUTION
Avatar of fundacionrts
fundacionrts
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of himabindu_nvn
himabindu_nvn

ASKER

Thank you!