On 14/02/2009 11:05, searchelite wrote: > select max(foo) from (select some statement) as foo Can you post the full query? It's very hard to tell from this. Also, I think you may need to give the subquery an alias, thus: select max(foo) from ( .... ) s as foo Ray. ------------------------------------------------------------------ Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland rod@xxxxxx Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals ------------------------------------------------------------------ -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general