RE: running totals - Mailing list pgsql-novice

From Joel Burton
Subject RE: running totals
Date
Msg-id 3A2E7AFE.1129.702A05B@localhost
Whole thread Raw
In response to Re: running totals  ("Joel Burton" <jburton@scw.org>)
Responses Re: running totals  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-novice
> >CREATE VIEW tape_view AS
> >SELECT id, tape_name, sum(runtime)
> >FROM tape t,
> >show s
> >WHERE t.id = s.tape_id
> >GROUP BY id, tape_name;
> >
> >Which means you can just
 >
> >SELECT * FROM tape_view;
>
> Wow! This is a great idea... I had never thought of using a view
for
> this type of calculation.  I always did it the hard way.  Question
> though, does the VIEW keep the sum current at all times, or does
it
> just update when a query is run on the VIEW?


The view *IS* a query, really. When you SELECT from the VIEW,
you're really running a SELECT. So, no, merely updating in the the
table doesn't affect the view, only when you select from the view.



--
Joel Burton, Director of Information Systems -*- jburton@scw.org
Support Center of Washington (www.scw.org)

pgsql-novice by date:

Previous
From: "Rob Yelle"
Date:
Subject: access.mdb import
Next
From: Andrew McMillan
Date:
Subject: Re: access.mdb import