Re: Updating table with max from another table - Mailing list pgsql-general

From Bjoern Metzdorf
Subject Re: Updating table with max from another table
Date
Msg-id 000f01c29583$db2e6360$0564a8c0@toolteam.net
Whole thread Raw
In response to Updating table with max from another table  ("Dan Winslow" <d.winslow@cox.net>)
List 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 by date:

Previous
From: Neil Conway
Date:
Subject: Re: EXECUTE problems
Next
From: Jean-Luc Lachance
Date:
Subject: Re: ALTER TRIGGER DISABLE/ENABLE