Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
KlausEngel
Yak Posting Veteran
85 Posts |
Posted - 2011-02-17 : 10:37:26
|
| I have a column with numeric values (23.0123456789).I would like to parse this number to find out if the 3 decimal is greater than '0'. How would I approach this?Thanks for your help. |
|
|
MIK_2008
Master Smack Fu Yak Hacker
1054 Posts |
Posted - 2011-02-17 : 10:52:49
|
| select (case when cast(substring(CAST(ColumnName as varchar(15)),CHARINDEX('.',reverse(CAST(ColumnName as varchar(15))))-4,1) AS tinyint)>3 then 'Yes' else 'No' end) as GreaterOrNot |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-02-17 : 10:59:42
|
| Or:SELECT CASE WHEN CAST(ColumnName * 1000 % 10 as int) > 0 THEN 'Yes' ELSE 'No' END FROM myTable |
 |
|
|
KlausEngel
Yak Posting Veteran
85 Posts |
Posted - 2011-02-17 : 11:22:44
|
| Fantastic - thanks! |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-02-18 : 10:30:54
|
| or1select case when data like '%.[0-9][0-9][1-9]%' then 'yes' else 'no' end FROM myTable2select case when data like '%.__[1-9]%' then 'yes' else 'no' end FROM myTableMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|