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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How do I express this equation in a query

Author  Topic 

kamikaze
Starting Member

8 Posts

Posted - 2010-03-11 : 21:15:42
how do i write this equation in sql query in a column

All of these field names have numerical values: Xa, Ya and Xb, Yb. Now what pythagoras says is that:

distance = square-root ( (Xb-Xa)2 + (Yb - Ya)2 )

The Problem is that writing this as query with "Distance" AS an EXPression. However the SQL server does not allow the "2" included in the equation throwing errors each time spitting back the 2's which are 'the quare root of' and important part in the value im trying to get.

ummm...

kamikaze
Starting Member

8 Posts

Posted - 2010-03-11 : 21:42:00
Nevermind... Got it now!

ummm...
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-03-12 : 02:26:26
Post the solution

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-03-12 : 04:00:33
I dont know whether you want as below or something else....

SELECT SQRT(POWER((Xb-Xa),2)+(POWER((Yb-Ya),2)))



Vabhav T
Go to Top of Page
   

- Advertisement -