Re: problem query ...

Поиск
Список
Период
Сортировка
От Ugly Hippo
Тема Re: problem query ...
Дата
Msg-id 20020202083402.10464.qmail@web21201.mail.yahoo.com
обсуждение исходный текст
Ответ на problem query ...  (John Taylor <postgres@jtresponse.co.uk>)
Список pgsql-novice
--- John Taylor <postgres@jtresponse.co.uk> wrote:
>
> Hi,
>
> I hope someone can help with this query, which is
> causing me great problems.
>
> I have a table:
> create table mytable ( id varchar(10), name
> varchar(10), desc varchar(10), update integer);
>
> I want to return 1 row for each id, that contains
> the maximum update value for that id, and
> the values for name and desc.

I would try (I can't connect to my db at the moment):

select id, max(name), max(desc), max(update)
from mytable
group by id;

HTH,
Troy
ugly_hippo@yahoo.ca

>
> I've tried everything I can think of, but no luck
> :-(
> I'm sure there is some simple trick that I'm
> missing.
>
> Can someone please put me out of my misery !
>
> Thanks
> JohnT
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: you can get off all lists at once with the
> unregister command
>     (send "unregister YourEmailAddressHere" to
majordomo@postgresql.org)


______________________________________________________________________
Web-hosting solutions for home and business! http://website.yahoo.ca

В списке pgsql-novice по дате отправления:

Предыдущее
От: Oliver Elphick
Дата:
Сообщение: Re: table design
Следующее
От: "PG Explorer"
Дата:
Сообщение: Re: problem query ...