At 15:50 +0100 1/10/01, Tim Bunce wrote:
>     I did a query: "select MAX(field) from ....';
>
>     But if the query did not select any row, the perl show $sth->rows == 1 and
>     the array with the values is not undefined. (the values are undefineds)
>
>     Apparently, the sqlplus show any row (undefined), but if i did
>     "select count(*) from ....';, the sqlplus show 0.

All aggregate functions always return one row per group (and there is 
always an implicit group - the set - when the 'group by' clause is 
not specified). Therefore the behaviour you note is correct and 
expected in relational (SQL) databases.

Note that count() returns one row whose value is 0 instead of 
returning zero rows. That is the same for max(), min(), avg(), etc. 
It is actually count() that is the odd one out, since it returns a 
'value' when no rows match the predicate but that is because its 
value is the number of matched rows where all other aggregate 
functions return a value based on the value of matched rows.

Regards

Paul Miller
-- 
-
Carib Data Limited

<mailto:[EMAIL PROTECTED]>
<http://www.caribdata.co.uk>

Reply via email to