Re: Updating table with max from another table

Поиск
Список
Период
Сортировка
От Bjoern Metzdorf
Тема Re: Updating table with max from another table
Дата
Msg-id 000f01c29583$db2e6360$0564a8c0@toolteam.net
обсуждение исходный текст
Ответ на Updating table with max from another table  ("Dan Winslow" <d.winslow@cox.net>)
Список pgsql-general
> update a from b such that a.maxtype is set equal to the b.type whose val
> number is the highest for that matching id, that is, the result

How about:

update a set maxtype = (select type from b where b.id = a.id order by val
desc limit 1);

?

Regards,
Bjoern


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

Предыдущее
От: Neil Conway
Дата:
Сообщение: Re: EXECUTE problems
Следующее
От: Jean-Luc Lachance
Дата:
Сообщение: Re: ALTER TRIGGER DISABLE/ENABLE