RE: [sqlite] Help wiith SQL - first row of each group

2007-05-08 Thread Adler, Eliedaat
e first row per group. Thanks again, Eliedaat -Original Message- From: Ed Pasma [mailto:[EMAIL PROTECTED] Sent: Monday, May 07, 2007 10:28 PM To: Adler, Eliedaat Cc: sqlite-users@sqlite.org Subject: RE: [sqlite] Help wiith SQL - first row of each group This solution may is tricky

Re: [sqlite] Help wiith SQL - first row of each group

2007-05-07 Thread Tomash Brechko
On Mon, May 07, 2007 at 19:20:49 +0400, Tomash Brechko wrote: > But with SQLite 3.x there is only one user data pointer per user > defined aggregate function, so no parallel aggregate execution is > possible. Ah, I was too fast again :/. GROUP BY is really two-pass, but my understanding why it

Re: [sqlite] Help wiith SQL - first row of each group

2007-05-07 Thread Tomash Brechko
On Mon, May 07, 2007 at 18:10:29 +0400, Tomash Brechko wrote: > The solution with two table scans might be > > SELECT * FROM RESULT_TABLE a > WHERE P = (SELECT MIN(P) FROM RESULT_TABLE b WHERE b.G = a.G); > > You may also try to play with indexes G, P. > > It seems to be impossible to do

RE: [sqlite] Help wiith SQL - first row of each group

2007-05-07 Thread Adler, Eliedaat
that "scans" TEST only once? -Original Message- From: Maulkye [mailto:[EMAIL PROTECTED] Sent: Monday, May 07, 2007 4:35 PM To: sqlite-users@sqlite.org Subject: Re: [sqlite] Help wiith SQL - first row of each group How about something like this: create table test ( G

Re: [sqlite] Help wiith SQL - first row of each group

2007-05-07 Thread Tomash Brechko
On Mon, May 07, 2007 at 15:38:22 +0300, Adler, Eliedaat wrote: > I need to define a query that returns only the "first' row in each group > - i.e. the row with the lowest display priority: > > - most preferably a query that doesn't require selecting RESULT_TABLE > more than once. The solution

Re: [sqlite] Help wiith SQL - first row of each group

2007-05-07 Thread Maulkye
How about something like this: create table test ( Grp text, Val text, Pri integer ) insert into test values ('A', 'X', 1) insert into test values ('A', 'X', 2) insert into test values ('B', 'Y', 4) insert into test values ('B', 'Z', 2) insert into test values ('B', 'X', 8) insert into test