|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Values b/w 0 and 1 needs to be decoded [message #416690 is a reply to message #416686] |
Tue, 04 August 2009 00:11   |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
The provided code in the last few post all forget to take into account negative numbers. The Orignal Poster clearly stated that only numbers between 0 and 1 need to be converted.
That is NOT the same as all numbers < 1
|
|
|
|
Re: Values b/w 0 and 1 needs to be decoded [message #416701 is a reply to message #416620] |
Tue, 04 August 2009 00:46   |
Neo06
Messages: 11 Registered: January 2008
|
Junior Member |
|
|
@Delna
Thanks for correcting me..
@Frank
Oops...may be from next time, I need to concentrate on details...
anyway I correted the code.. hope this should be fine.. using Delnas code..
SELECT CASE
WHEN net_weight > 0.00 and net_weight < 1.00 THEN 1
ELSE net_weight
END ,net_weight
FROM tbl;
|
|
|
Re: Values b/w 0 and 1 needs to be decoded [message #416702 is a reply to message #416701] |
Tue, 04 August 2009 00:48   |
pablolee
Messages: 2882 Registered: May 2007 Location: Scotland
|
Senior Member |
|
|
Couple of minor things neo, neither of them actual problems as far as execution goes:
No need for the extra zeros:
WHEN net_weight > 0 and net_weight < 1 THEN 1
add an alias nto expression columns, just to keep things tidy.
|
|
|
Re: Values b/w 0 and 1 needs to be decoded [message #416703 is a reply to message #416701] |
Tue, 04 August 2009 00:54  |
 |
delna.sexy
Messages: 941 Registered: December 2008 Location: Surat, The Diamond City
|
Senior Member |
|
|
Agree with pablolee sir
Quote: | I have a requirement of converting values of a column between
0 and 1 to 1.
|
Quote: | select (case net_weight WHEN 0.% then 1
|
And to convert 0 into 1, condition should be like
WHEN net_weight >= 0 and net_weight < 1 THEN 1
regards,
Delna
|
|
|