Look at the NOTICE:
siprebi=> SELECT max(tprestamo.cantmaxpres) FROM tprestamo t,usuarios
u,personas p,objetos o, tipodoc td WHERE t.cateusuario = u.cateusuario AND
u.persona = p.codigo AND p.docnum = 23622139 AND p.tdocu = td.codigo AND
td.nombre = 1 AND t.cateobjeto = o.cateobjeto AND o.ninventario = 29 AND
o.uacademi = 4;
NOTICE: Adding missing FROM-clause entry for table "tprestamo"
Now, look at the exact same query, only changing the field in max(), which is
the same, only that I use the alias of the table:
siprebi=> SELECT max(t.cantmaxpres) FROM tprestamo t,usuarios u,personas
p,objetos o, tipodoc td WHERE t.cateusuario = u.cateusuario AND u.persona =
p.codigo AND p.docnum = 23622139 AND p.tdocu = td.codigo AND td.nombre = 1
AND t.cateobjeto = o.cateobjeto AND o.ninventario = 29 AND o.uacademi = 4;
max
-----
Looks like a bug.
siprebi=> select version();
version
------------------------------------------------------------------------------
PostgreSQL 7.3.2 on sparc-unknown-linux-gnu, compiled by GCC gcc (GCC) 3.2.3
(1 row)
--
10:33:01 up 17 days, 17:55, 3 users, load average: 0.34, 0.41, 0.41
-----------------------------------------------------------------
Martín Marqués | select 'mmarques' || '@' || 'unl.edu.ar'
Centro de Telematica | DBA, Programador, Administrador
Universidad Nacional
del Litoral
-----------------------------------------------------------------