0

I nead to buid a query in SQLite for an android app I read that It's not possible to use math functions in the query, there 's any way to do it like load an extension or something similar.

any answear is wellcome, thanks in advance.

Xenione
  • 2,174
  • 1
  • 23
  • 30
  • Can you give an example what you want to do? An example or so. – harshit Sep 05 '12 at 10:55
  • I ' m using querymanaged it's the way to query database through a ContentProvider, one of the querymanaged parameters is OrderBy and I need to OrderBy sqrt(first_column*second_column) – Xenione Sep 05 '12 at 10:58
  • For this example, `ORDER BY first_column*second_column` results in exactly the same order. – CL. Sep 05 '12 at 11:19
  • yes I Know. I try to simplify. it's more complex is mothing like that sqrt((column_lat-latMe)^2-(column_lng-lngMe)^2), and also I wanted to get in the query so the only solution is to used maths functions in sqlite. – Xenione Sep 05 '12 at 11:37
  • `sqrt` is a monotonic transformation; you can always drop it from `ORDER BY` expressions. – CL. Sep 05 '12 at 11:47
  • No. I got this error: not such function sqrt, I read that in SQLite is not possible to use math functions. – Xenione Sep 05 '12 at 11:58
  • You just don't need to use `sqrt` and all will be good. – Dmitry Mar 16 '13 at 17:38

1 Answers1

0

SQLite itself allows to add user-defined functions, but this is not exposed in the Android API.

You'd have to use the NDK: how to create a user defined function in SQLITE?

Community
  • 1
  • 1
CL.
  • 173,858
  • 17
  • 217
  • 259