I think

select * from mytable where rowid %5 = 0;

will get you something like every fifth row in the table.  But that assumes 
your rowids are 1-nnn with no gaps.  If your rowids happen to skip a value 
evenly divisible by 5, you won't get another row until the next one divisible 
by 5.

 -Clark


----- Original Message ----
From: Uma Venkataraman <[EMAIL PROTECTED]>
To: sqlite-users@sqlite.org
Sent: Monday, March 27, 2006 11:07:18 AM
Subject: Re: [sqlite] help with sqlite command

Hi Jay,

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?

Thanks
Uma



----- Original Message ----- 
From: "Jay Sprenkle" <[EMAIL PROTECTED]>
To: <sqlite-users@sqlite.org>
Sent: Monday, March 27, 2006 1:56 PM
Subject: Re: [sqlite] help with sqlite command


On 3/27/06, Uma Venkataraman <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I need to be able to select  the TOP N rows from a table. How do i do it =

select * from mytable limit 5


> with sqlite? Also  how does one select EVERY Nth row from a table?

use modulus operator for that:
select * from mytable where row_id = row_id % 5



---
On Wednesday, March 1, 2006, at a hearing on the proposed
Constitutional Amendment to prohibit gay marriage, Jamie Raskin,
professor of law at AU, was requested to testify.

At the end of his testimony, Republican Senator Nancy Jacobs said:
"Mr. Raskin, my Bible says marriage is only between a man and a woman.
What do you have to say about that?"

Raskin replied: "Senator, when you took your oath of office, you
placed your hand on the Bible and swore to uphold the Constitution.
You did not place your hand on the Constitution and swear to uphold
the Bible."

The room erupted into applause. 




Reply via email to