question

Gogolo avatar image
Gogolo asked

sql formula from xls

Dears, I have to convert a xls formula to sql, but Im havinfg some problems with power function, can anyone help me on that, the formula looks as below: (AX10+AY10)/(SQRT((AX10+AY10)^2+(AZ10+BA10)^2))) I tried in this way but it wont work.. (([fld1]+[fld2])/(SQRT(([fld1]+[fld2])POWER(2)+[fld3]+[fld4])power(2)))) I appreciate your help, Thank you in advanced
sqlmathematics
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Kev Riley avatar image Kev Riley ♦♦ commented ·
In what way does it not work? Does it give you an incorrect answer, or is it erroring?
0 Likes 0 ·
Kev Riley avatar image
Kev Riley answered
`POWER()` function requires 2 arguments, so I think you want (([fld1]+[fld2])/(SQRT(POWER(([fld1]+[fld2]),2)+power(([fld3]+[fld4]),2))))
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Gogolo avatar image Gogolo commented ·
Thanks a lot Kev..:), this is what I needed
0 Likes 0 ·
Fatherjack avatar image
Fatherjack answered
The POWER function takes two arguments - http://msdn.microsoft.com/en-US/library/ms174276(v=SQL.90).aspx DECLARE @value int, @counter int SET @value = 2 SET @counter = 1 WHILE @counter < 5 BEGIN SELECT POWER(@value, @counter) SET NOCOUNT ON SET @counter = @counter + 1 SET NOCOUNT OFF END GO returns 2 4 8 16
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.