Question:

Given a table TBL with a field Nmbr that has rows with the following values:

1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1

Write a query to add 2 where Nmbr is 0 and add 3 where Nmbr is 1.

Answer:

This can be done as follows:

update TBL set Nmbr = case when Nmbr > 0 then Nmbr+3 else Nmbr+2 end;

Keywords:

© 2017 QuizBucket.org