Click here to Skip to main content
14,639,458 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi I want to replace multiple values within in a column, and leave the rest at default.
the values that should be replaced are those less than 1 with 2.00.

I've tried the code beneath, but didn't work.
Anyone who can give me a pointer in the right direction?

Thanks

What I have tried:

SELECT Production.price
CASE
WHEN Cost < 1 THEN '2.00'
END
FROM production;
Posted
Updated 9-Sep-20 11:48am
Rate this:
Please Sign up or sign in to vote.

Solution 2

Try:
UPDATE Production SET Price = 2.0 WHERE Cost < 1
   
Rate this:
Please Sign up or sign in to vote.

Solution 1

SELECT Production.price
CASE
WHEN Cost < 1 THEN '2.00'
END
FROM production; 

Problem: your syntax (even though you didn't tell us that's the problem).

Like what should it do when when cost >=1 (an ELSE option). It's really quite a mess for so little code - at least in so far as you've given no information about the source of your data. Or even what the problem is (doesn't work isn't helpful)
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100