On Thu, Jun 05, 2008 at 03:55:44PM -0700, Scott Baker scratched on the wall:
> I have a database with coordinates in it. I'd like to calculate distance at 
> the SQL level, but the equation for calculating distance requires square 
> root and I'm not sure if I can do this with sqlite. Something like:
> 
> SELECT PlaceName, sqrt((PlaceX - 1)^2 - (PlaceY - 3)^2) AS DistFromHome 
> FROM Table WHERE PlaceGroup = 3;

  Be aware that SQLite doesn't recognize the ^ operator.

> What mathematical functions can I do at the sqlite level? I'll preface this 
> with, with stock SQLite (no added components) as it's on a shared web host.

  If you must use a vanilla SQLite install, the built-in functions are
  listed here:

  http://www.sqlite.org/lang_corefunc.html
  http://www.sqlite.org/lang_aggfunc.html

  If you don't want to deal with extensions but can modify the SQLite
  binary, it is very easy to add your own functions directly to the
  SQLite library.  See src/func.c for more info.

   -j

-- 
Jay A. Kreibich < J A Y  @  K R E I B I.C H >

"'People who live in bamboo houses should not throw pandas.' Jesus said that."
   - "The Ninja", www.AskANinja.com, "Special Delivery 10: Pop!Tech 2006"
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to