I do i express this equation in a query

  • 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.

  • You might want to check out the POWER and SQRT functions in BOL.

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • Thank y:Wow:u,

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply