simone simone - 9 months ago 118
SQL Question

How to calculate square root in sqlite

I need to calculate an euclidean distance in a sqlite database.

Does anyone know how to calculate square roots in sqlite beside writing and loading a dynamic library for math functions?

I am close to resorting to the fast inverse square root algorithm in here though it might to turn into more fun than I need right now.

And as a side note, it'd be great to figure out how to do power (which is the generalized question, and is cleaner coding than multiplying a number by itself).



Answer Source

Well, I have a semi-answer.

Yes it involves a 3rd party, but you don't have to write it yourself : did you check the last extension on this page ?

It includes several math functions, and amongst them is sqrt().