B*********L 发帖数: 700 | 1 下面这个query(其中B是个长公式),column3 就是 column1 乘以 column2,
SQL server总是给我0.
SELECT
A
,POWER(cast(10 as dec(38,20)),B)
,A*POWER(cast(10 as dec(38,20)),B)
FROM TABLE_A
result:
8694 0.00000000003548134000 0.00000000000000000000
2103 0.00000000003981072000 0.00000000000000000000
对column3,我试过以下几种办法,都不行。
,CAST(A as dec(38,20))*POWER(cast(10 as dec(38,20)),B)
,CAST(A as dec(38,20))*CAST(A POWER(cast(10 as dec(38,20)),B) as dec(38,20))
,CAST(CAST(A as dec(38,20))*CAST(A POWER(cast(10 as dec(38,20)), | B*********L 发帖数: 700 | 2
Solved:
cast(A as float)*POWER(cast(10 as dec(38,20)),B)
【在 B*********L 的大作中提到】 : 下面这个query(其中B是个长公式),column3 就是 column1 乘以 column2, : SQL server总是给我0. : SELECT : A : ,POWER(cast(10 as dec(38,20)),B) : ,A*POWER(cast(10 as dec(38,20)),B) : FROM TABLE_A : result: : 8694 0.00000000003548134000 0.00000000000000000000 : 2103 0.00000000003981072000 0.00000000000000000000
| j*****n 发帖数: 1781 | 3 you probably want do the CAST(A as dec(38,20)) as well. Since converting to
float may give you some exceptional numbers. Just my 2 cents.
【在 B*********L 的大作中提到】 : : Solved: : cast(A as float)*POWER(cast(10 as dec(38,20)),B)
| B*********L 发帖数: 700 | 4 Thanks.
I don't know why, but CAST(A as dec(38,20)) gives me 0.00000000000
Only float works.
to
【在 j*****n 的大作中提到】 : you probably want do the CAST(A as dec(38,20)) as well. Since converting to : float may give you some exceptional numbers. Just my 2 cents.
|
|