On 3/9/2010 8:04 AM, P Kishor wrote: > >> select min(88,99) from T where 1=2 // returns 0 rows >> > The above is correct SQL and the answer is correct. Per the docs, > "Note that min() is a simple function when it has 2 or more arguments > but operates as an aggregate function if given only a single > argument." > > Finally, note that when returning both aggregate and non-aggregate > columns, you should use the GROUP BY clause. I believe that SQLite > will return rows even without GROUP BY, but the answer may be > undependable. >
Of these three: select c from T where 1=2 // returns 0 rows select min(c) from T where 1=2 // returns 1 row select min(88,99) from T where 1=2 // returns 0 rows the only case that "threw" me is the second one, where a row is returned despite a WHERE condition that should yield an empty set (or so I thought). Regarding your point about the GROUP BY clause -- I'm not sure what you mean by "non-aggregate columns". Are you referring to a query where one wants to find the minimum value in a given column for the /entire/ table? select min(askingprice) from cars4sale group by rowid //<= a group by is required here? Regards Tim Romano _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users