Sqlite: Selecting records spread over total records
Posted
by Martin
on Stack Overflow
See other posts from Stack Overflow
or by Martin
Published on 2010-04-28T13:23:07Z
Indexed on
2010/04/28
13:43 UTC
Read the original article
Hit count: 383
I have a sql / sqlite question. I need to write a query that select some values from a sqlite database table. I always want the maximal returned records to be 20. If the total selected records are more than 20 I need to select 20 records that are spread over the total records. It is also important that I always select the first and last value from the table when sorted on the date.
I know how to accomplish this in code but it would be perfect to have a sqlite query that can do the same.
The query Im using now is really simple and looks like this:
"SELECT value,date,valueid FROM tblvalue WHERE tblvalue.deleted=0 ORDER BY DATE(date)"
Hope I explained what I need, thanks for your help!
© Stack Overflow or respective owner