由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - MSSQL Power Function
相关主题
问个SQL Query一个SQL写法性能的请教
求教sql的power() functionchange year format in Access by SQL query (转载)
Rookie's question againPL/SQL function 使用求教?
random error for CAST( MONEY AS VARCHAR)for round() function in SQL
一个关于impala query的问题也来问个SQL的问题
DB2 Stored Procedure Error HandlerPIVOT question
SQL questionthe most stupid question
DUMMY question: Intro to SQL.请教一个query in mysql
相关话题的讨论汇总
话题: cast话题: power话题: dec话题: 38话题: 20
进入Database版参与讨论
1 (共1页)
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.

1 (共1页)
进入Database版参与讨论
相关主题
请教一个query in mysql一个关于impala query的问题
请教一个SQL Server的面试题DB2 Stored Procedure Error Handler
请教mssql一个问题, 关于add extended properties only to float fieldSQL question
sql high hand please help.DUMMY question: Intro to SQL.
问个SQL Query一个SQL写法性能的请教
求教sql的power() functionchange year format in Access by SQL query (转载)
Rookie's question againPL/SQL function 使用求教?
random error for CAST( MONEY AS VARCHAR)for round() function in SQL
相关话题的讨论汇总
话题: cast话题: power话题: dec话题: 38话题: 20