Re: join problem or maybe group :(

From: "Henshall, Stuart - WCP" <SHenshall(at)westcountrypublications(dot)co(dot)uk>
To: 'Diogo Biazus' <diogo(at)ikono(dot)com(dot)br>, Ben-Nes Michael <miki(at)canaan(dot)co(dot)il>
Cc: postgres <pgsql-general(at)postgresql(dot)org>
Subject: Re: join problem or maybe group :(
Date: 2002-08-30 13:21:18
Message-ID: E2870D8CE1CCD311BAF50008C71EDE8E01F74993@MAIL_EXCHANGE
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

There is a non-ansi way of doing it:
SELECT column1,column2 FROM table ORDER BY column1 DESC LIMIT 1;
- Stuart

> -----Original Message-----
> From: Diogo Biazus [mailto:diogo(at)ikono(dot)com(dot)br]
>
>
> I think that a subselect will do that, but I'm not sure if it is the
> best way.
> Try something like:
>
> select max(column1), (select column2 from table where column1
> = (select max(column1) from table)) from table;
>
>
> >Just wonder, how can i do:
> >
> >select max(column1), column2 from table;
> >
> >its saying:
> >ERROR: Attribute table.column2 must be GROUPed or used in
> an aggregate
> >function
> >
> >and all i want is that column2 value will be the mate fo column1 max?
> >
> >like if
> >clumn1 column2
> >1 a
> >2 b
> >3 c
> >
> >it will return 3,c
> >
>
> --
> Diogo de Oliveira Biazus
> diogo(at)ikono(dot)com(dot)br
> Ikono Sistemas e Automação
> http://www.ikono.com.br
>
>
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

Browse pgsql-general by date

  From Date Subject
Next Message Christoph Dalitz 2002-08-30 13:39:28 Re: postmaster respawn....?
Previous Message Daryl Beattie 2002-08-30 13:17:35 Re: Selecting Varchar range (through JDBC).