select max from subquery

Started by searcheliteabout 17 years ago5 messagesgeneral
Jump to latest
#1searchelite
searchelite@gmail.com

Dear All

i gave this kind of query

select max(foo) from (select some statement) as foo

but it gave me this error
ERROR: function max(record) does not exist

any help how i can select max value from suqbuery in main query

thanks
--
View this message in context: http://www.nabble.com/select-max-from-subquery-tp22011562p22011562.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

In reply to: searchelite (#1)
Re: select max from subquery

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@iol.ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------

#3Grzegorz Jaśkiewicz
gryzman@gmail.com
In reply to: searchelite (#1)
Re: select max from subquery

select max(foo.record) from ...
?

#4Oleg Bartunov
oleg@sai.msu.su
In reply to: searchelite (#1)
Re: select max from subquery

yOn Sat, 14 Feb 2009, searchelite wrote:

Dear All

i gave this kind of query

select max(foo) from (select some statement) as foo

but it gave me this error
ERROR: function max(record) does not exist

any help how i can select max value from suqbuery in main query

like this:

select max(foo.qq) from (select 1 as qq) as foo;
^^ ^^

thanks

Regards,
Oleg
_____________________________________________________________
Oleg Bartunov, Research Scientist, Head of AstroNet (www.astronet.ru),
Sternberg Astronomical Institute, Moscow University, Russia
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(495)939-16-83, +007(495)939-23-83

#5searchelite
searchelite@gmail.com
In reply to: Oleg Bartunov (#4)
Re: select max from subquery

Oleg Bartunov wrote:

yOn Sat, 14 Feb 2009, searchelite wrote:

Dear All

i gave this kind of query

select max(foo) from (select some statement) as foo

but it gave me this error
ERROR: function max(record) does not exist

any help how i can select max value from suqbuery in main query

like this:

select max(foo.qq) from (select 1 as qq) as foo;
^^ ^^

thanks

Regards,
Oleg
_____________________________________________________________
Oleg Bartunov, Research Scientist, Head of AstroNet (www.astronet.ru),
Sternberg Astronomical Institute, Moscow University, Russia
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(495)939-16-83, +007(495)939-23-83

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

thanks oleg for your reply..that's what i need ;)

--
View this message in context: http://www.nabble.com/select-max-from-subquery-tp22011562p22021619.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.