On Wed, Oct 29, 2014 at 4:28 PM, Staffan Tylen <staffan.ty...@gmail.com> wrote:
> But if several rows have the same a value as the max value then the b value > will be arbitrary, or? > Then b will be from one of the rows for which a is maximal - but you don't know which one. Similarly, if you say: SELECT max(a), max(c), min(d), max(e+f), b FROM table WHERE ...; Then the b value will be from one of the rows where either a was maximal or c was maximal or d was minimal or e+f was maximal - but if there are multiple rows that meet that criterion, you don't know which row you'll get. > > Staffan > > > On Wed, Oct 29, 2014 at 7:43 PM, Richard Hipp <d...@sqlite.org> wrote: > > > On Wed, Oct 29, 2014 at 2:38 PM, Baruch Burstein <bmburst...@gmail.com> > > wrote: > > > > > Hi, > > > > > > If I have a table, "t", with 2 columns, "a" and "b". Assuming that "a" > > is a > > > unique number, will the following query always return the whole row > (that > > > is, with the correct "b" column) where "a" is the highest number below > > 50? > > > > > > SELECT max(a), b FROM t WHERE a<50; > > > > > > > > That is what it is suppose to do, yes. > > > > Note that SQL is unique among SQL database engines in supporting this > > behavior. All other SQL database engines (that I know about) will either > > report the query above as an error, because column b is not in the GROUP > BY > > clause and is not inside an aggregate function, or will return b from an > > arbitrary row, not necessarily the row on which a is maximal. > > > > -- > > D. Richard Hipp > > d...@sqlite.org > > _______________________________________________ > > sqlite-users mailing list > > sqlite-users@sqlite.org > > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > -- D. Richard Hipp d...@sqlite.org _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users