February 24, 2009 at 4:06 am
hi friends,
i have some expression in excel which looks like below.
=(175*((95*0.011312)^-1.154))*((65)^-0.203)
The answer to above calculation is 69.
How can i write it using TSQL?
thanks,
Vijay
February 24, 2009 at 4:28 am
select 175*(power((95*0.011312),-1.154))*power(CONVERT(FLOAT,65),(-0.203)) as cal
John Smith
February 24, 2009 at 4:34 am
Either you first declare all the numbers in in float or numeric variables, or you CAST all the numbers in the SELECT. I chose for the first to give you an example:DECLARE @N1 AS FLOAT, @N2 AS FLOAT, @N3 AS FLOAT, @N4 AS FLOAT, @N5 AS FLOAT, @N6 AS FLOAT
SELECT @N1 = 175, @N2 = 95, @N3 = 0.011312, @N4 = -1.154, @N5 = 65, @N6 = -0.203
SELECT (@N1*POWER((@N2*@N3),@N4))*POWER(@N5,@N6)
Ronald HensbergenHelp us, help yourself... Post data so we can read and use it: http://www.sqlservercentral.com/articles/Best+Practices/61537/-------------------------------------------------------------------------2+2=5 for significant large values of 2
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply