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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 simple arithmetical operations

Author  Topic 

aliaj
Starting Member

1 Post

Posted - 2008-10-02 : 12:39:41
Hello there,

I am quite new to SQL and programming in general and am desperate for some help for a task I need to submit urgently:

I have the following formula which I need to code in SQL in the SQL Server Management Studio:

KEY = SQRT[(GPZ*2 + ITS)^2]

GPZ and ITS are positive numbers so I guess they could be declared as float and as a result so could be KEY

I get confused trying to define and then declare those variables and then writing this formula and displaying it.

if those variables were columns, how would that be coded?

Thank You so very much for your help in advance!

RyanRandall
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2008-10-02 : 13:26:16
This example might help...

declare @t table (GPZ float, ITS float)
insert @t
select 10, 20
union all select 20, 30

select *, sqrt(power(GPZ*2 + ITS, 2)) as [KEY] from @t


Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
Go to Top of Page

RyanRandall
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2008-10-02 : 13:28:18
By the way: I'm sure you realise the squaring and square-rooting cancel out...

Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
Go to Top of Page
   

- Advertisement -