0

So I wanted to do an "update" to any item that is in the domain [FirstItem +5 or - 5] example:

i have a table like:

462 458 768 466

after the update it will be like:

462 462 768 462

because:

458 and 466 are included in the domain [457.458.459.460.461(462)463.464.465.466.467]

I hope I was clear

user3448506
  • 41
  • 1
  • 7

1 Answers1

0

Provided that your SQL have support for the WITH command, you might do the following:

WITH MyItem(fItem) AS (SELECT first(item) as fItem FROM TableName) 
Update TableName SET Item = fItem
WHERE Item Between fItem-5 AND fItem+5

If first command don't exists try

WITH MyItem(fItem) AS (SELECT TOP 1 item as fItem FROM TableName) 
Update TableName SET Item = fItem
WHERE Item Between fItem-5 AND fItem+5