Updating - Mailing list pgsql-sql

From Bob Kruger
Subject Updating
Date
Msg-id 3.0.5.32.19990616120624.007e95e0@mindspring.com
Whole thread Raw
List pgsql-sql
Thanks for all who assisted with my previous question on grouping.

I would like to do an update of a table with the results of a query on
another.

For example:

table vehcost

id        serial
po        varchar(12)
veh_no        varchar(8)
cost        real
comments    varchar(30)


table vehinfo

id            serial
veh_no        varchar(12)
m_cost        real
...


I would like to take the sum of vehcost.veh_no and update that info to
field vehinfo.m_cost.

So far, I have worked with the following without success:

update vehinfo set m_cost = (select sum(vehcost.cost) from vehcost group by
veh_no) where vehinfo.veh_no = vehcost.veh_no ; 

Any ideas.

Thanks in advance for any assistance.

Regards - Bob Kruger




pgsql-sql by date:

Previous
From: José Soares
Date:
Subject: Re: [SQL] date
Next
From: Ravneet Mann
Date:
Subject: help needed