Tim Romano <tim.rom...@yahoo.com> wrote: > 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).
Aggregate functions work this way, yes. > Regarding your point about the GROUP BY clause -- I'm not sure what > you mean by "non-aggregate columns". Expressions in the SELECT list that don't mention aggregate functions. As in select x, min(y) from T; > 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? A GROUP BY doesn't make sense here. Without GROUP BY, the whole table (more precisely, all the rows matching the WHERE clause, if any) is in one group, and minimum is calculated across that group (if the group is empty, min() produces null). With GROUP BY clause, every individual row is in its own separate group, and minimum is calculated for each row, which is rather pointless. Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users