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 |
|
real_pearl
Posting Yak Master
106 Posts |
Posted - 2004-10-31 : 23:36:44
|
| Here are the valuesdeclare @MyTable Table(T1 float)insert into @MyTableselect 5.00E-02 union allselect 5.00E-02 union allselect 0.1 union allselect 0 union allselect 0.15 union allselect 0 union allselect 0.15 union allselect 0.25 union allselect 0 union allselect 5.00E-02 union allselect 0.1 union allselect 0.15 union allselect 0.15 union allselect 0.25 union allselect 0.3 union allselect 0.35 union allselect 0.4 union allselect 0.9 union allselect 1.15 union allselect 1.4 union allselect 1.4 union allselect 1.4 union allselect 0.35 union allselect 0.4 union allselect 0.6 union allselect 0.7 union allselect 0.75 union allselect 0.85 union allselect 1.45 union allselect 1.75 union allselect 1.85 union allselect 1.85 union allselect 2.05 union allselect 5select T1 from @MyTableselect LOG10(ABS(T1)) T1 from @MyTableWhen I run select query without using Log10 function ut returns me 34 rows but when I use Log10 function, the query returns 3 rows. How can I get the same number of rows even using Log10 function. While if you use log10 function on the individual value it returns some value e.g.,select LOG10(ABS(1.85))Please tell me how to solve this issue |
|
|
Arnold Fribble
Yak-finder General
1961 Posts |
Posted - 2004-11-01 : 03:17:06
|
| You'd have to prevent the domain error that will occur for the rows that have 0.0 in them:select CASE WHEN T1 = 0.0 THEN NULL ELSE LOG10(ABS(T1)) END T1 from @MyTableThough I'm not really clear what why you want positive and negative values to give the same result. Perhaps you should decide on some smallest possible value and use LOG10(T1-@smallestPossibleValue+@epsilon) so the parameter of the LOG10 function is always positive. |
 |
|
|
real_pearl
Posting Yak Master
106 Posts |
Posted - 2004-11-01 : 04:42:21
|
| Thanks Arnold, I utimately did the similar. |
 |
|
|
|
|
|