Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread UPDATE
Mon, Feb 25 2008 4:00 PMPermanent Link

"Andrej Bivic"
Have a master / detail situation. How do I write a query, which would sum
detail records  and write into a master record? And that for each master
record.
please, advise

Mon, Feb 25 2008 4:26 PMPermanent Link

"Robert"

"Andrej Bivic" <andrej.bivic@abitrade.si> wrote in message
news:9A24B40C-EE50-4280-A041-CE81641AE34D@news.elevatesoft.com...
> Have a master / detail situation. How do I write a query, which would sum
> detail records  and write into a master record? And that for each master
> record.

The obvious question is "why?". But assuming you need that, I like to use a
script, something like

selec mast_id, sum(field) as d_total
into memory\temp
from detail
group by mast_id;
create index byid on memory\temp (mast_id);
update master set m_total = d_total
from master
join memory\temp on id = mast_id;
drop table memory\temp;

Robert

> please, advise
>

Image