Thread: select MIN/MAX when no row selected

select MIN/MAX when no row selected

From
"Ricardo Coelho"
Date:
Hi All,

I think I had read this question with count(*) before.....

PgSql returns one row with a null field when we use select MIN or MAX on a
table, but the result should be "no rows selected".

I didn't try with C function, but I got the same result with psql.

So, I'm sending a Java example to Peter.

try {   rs=stmt.executeQuery("select min(field1) from tab where
field1>maxValueOfField1");   if (rs.next()) {       System.out.println("I found a row !!!!");
theResult=rs.getString(1);      if (theResult==null)           System.out.println("Min of field1 is NULL !!!!");   }
 
} catch (.............

maxValueofField1 = select max(field1) from tab;

Is it correct ?

I'm using PgSql 6.5.2, RHLinux/Intel 6.0

Thanks,

Ricardo Coelho.