> Wrapping a column in the min() function causes a query that returns no > rows to return a row?
Yes, it's SQL standard for aggregate functions (min, max, avg and count): without GROUP BY clause they always return one row. Pavel On Tue, Mar 9, 2010 at 7:18 AM, Tim Romano <tim.rom...@yahoo.com> wrote: > Wrapping a column in the min() function causes a query that returns no > rows to return a row? > > 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 > > Tim Romano > > On 3/9/2010 4:15 AM, Martin.Engelschalk wrote: >> Hi, >> >> try this: >> >> select coalesce(min(length), 0) from t where id = ? >> >> Martin >> >> Andrea Galeazzi schrieb: >> >>> Hi All, >>> I've got a table T made up of only two fields: INT id (PRIMARY KEY) and >>> INT length. >>> I need a statement in order to yield 0 when the key doesn't exist. At >>> this moment the query is too simple: >>> SELECT length FROM T WHERE id = ? >>> Any idea about it? >>> > > _______________________________________________ > 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