Click here to Skip to main content
15,903,828 members
Please Sign up or sign in to vote.
1.00/5 (1 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

Try:
SQL
UPDATE Production SET Price = 2.0 WHERE Cost < 1
 
Share this answer
 
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)
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900