0

If you check SELECT sqlite clause: https://www.sqlite.org/lang_select.html

You will see OFFSET demands EXPR. to get correct result from your database query. And when I went checking what is EXPR. (Please see this: https://www.sqlite.org/syntax/expr.html) i see theoretically there should be a way to express a function after offset. For an example:

select * from my_table limit 50 offset count(id);

Count function would give you numeric value, however we know this is not possible. So my question is: Is there any way to add functions to offset or am I reading things in wrong way from links?

mssqlw
  • 73
  • 9

2 Answers2

1

It is possible to use functions in the LIMIT/OFFSET expressions:

SELECT 42 LIMIT length('x') OFFSET round(0.123);

The count() function does not work here because it is an aggregate function, and inside the OFFSET clause, there is no table or group over which it could be applied.

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

It does not work in general. You have to select your count(id) in an extra query.

For more help look here: Sqlite LIMIT / OFFSET query

Community
  • 1
  • 1
Steffomio
  • 356
  • 3
  • 6