> Thanks for your reply. I am trying the command > > select * from mytable where row_id = row_id % 5 > > from sqlite browser and it says, no such column row_id.. Also I replaced > row_id with rowid and it gave only the first 4 records from my table. My > other concern is I will be deleting and adding records to the table. If I > want to select every nth record after such deletions and additions will the > row id not get affected?
Sorry, I'm a little off today and wrote the wrong formula! To get the even numbered records use: where rowid % 2 = 0 To get the odd numbered records use: where rowid % 2 = 1 To get every 5th record where rowid % 5 = 0 ( this will return record 5, 10, 15, etc). look up the 'modulus' or 'modulo' operator to see what this does. I believe rowid is assigned dynamically to the result set so it would give a different set of results for a different query. If you want the same records from different select statements you could create an integer column with a primary key and use that instead of rowid.