Re: [sqlite] max() with LIMIT

2011-08-31 Thread Kees Nuyt
On Wed, 31 Aug 2011 08:12:10 -0400, "Igor Tandetnik" wrote: >Ivan Shmakov wrote: >>> Tobias Vesterlund writes: >>> Is it possible to get the highest value in a "limited column" when >>> using LIMIT? >> >> Sure. >> >> SELECT max (id) FROM (SELECT

Re: [sqlite] max() with LIMIT

2011-08-31 Thread Ivan Shmakov
> Igor Tandetnik writes: > Ivan Shmakov wrote: > Tobias Vesterlund writes: >>> Is it possible to get the highest value in a "limited column" when >>> using LIMIT? >> Sure. >> SELECT max (id) FROM (SELECT id FROM t WHERE id > 0 LIMIT 10); > This only

Re: [sqlite] max() with LIMIT

2011-08-31 Thread Simon Slavin
On 31 Aug 2011, at 8:38am, Tobias Vesterlund wrote: > Is it possible to get the highest value in a "limited column" when using > LIMIT? Sort by that value. For instance, SELECT id FROM t ORDER BY id DESC LIMIT 1 will give you the biggest value of 'id' that can be found. It's not needed in

Re: [sqlite] max() with LIMIT

2011-08-31 Thread Igor Tandetnik
Tobias Vesterlund wrote: > But If I do SELECT max(id) FROM t WHERE id > 0 LIMIT 10; it will return 99. > > My logic, which may be flawed in this case, tells me the third SELECT should > return 10 and not 99. > > Is it possible to get the highest value in a

Re: [sqlite] max() with LIMIT

2011-08-31 Thread Igor Tandetnik
Ivan Shmakov wrote: >> Tobias Vesterlund writes: >> Is it possible to get the highest value in a "limited column" when >> using LIMIT? > > Sure. > > SELECT max (id) FROM (SELECT id FROM t WHERE id > 0 LIMIT 10); This only works by accident. There's no requirement

Re: [sqlite] max() with LIMIT

2011-08-31 Thread Kees Nuyt
On Wed, 31 Aug 2011 09:38:46 +0200, Tobias Vesterlund wrote: > Hi, > > I'm want to get the max value out of a certain column in a table. > > Table t has a column named id, which ranges from 0 to 99. > > If I do SELECT max(id) FROM t; > it will return 99. > If I

Re: [sqlite] max() with LIMIT

2011-08-31 Thread Tobias Vesterlund
Right you are, thank you! Regards, Tobias -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Ivan Shmakov Sent: den 31 augusti 2011 10:13 To: sqlite-users@sqlite.org Subject: Re: [sqlite] max() with LIMIT >>>

Re: [sqlite] max() with LIMIT

2011-08-31 Thread Ivan Shmakov
> Tobias Vesterlund writes: […] > If I do SELECT max(id) FROM t; it will return 99. > If I do SELECT id FROM t WHERE id > 0 LIMIT 10; it will return > 1,2,3,4,5,6,7,8,9,10 > But If I do SELECT max(id) FROM t WHERE id > 0 LIMIT 10; it will > return 99. > My logic, which may be flawed

[sqlite] max() with LIMIT

2011-08-31 Thread Tobias Vesterlund
Hi, I'm want to get the max value out of a certain column in a table. Table t has a column named id, which ranges from 0 to 99. If I do SELECT max(id) FROM t; it will return 99. If I do SELECT id FROM t WHERE id > 0 LIMIT 10; it will return 1,2,3,4,5,6,7,8,9,10 But If I do SELECT max(id) FROM