From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
To: Gary Stainburn <gary.stainburn@ringways.co.uk>
Cc: pgsql-sql@postgresql.org
Subject: Re: sub-select, view and sum()
Date: Mon, 6 Jan 2003 10:31:29 -0800 (PST)
Message-ID: <20030106102933.K47795-100000@megazone23.bigpanda.com> (raw)
In-Reply-To: <200301061729.07459.gary.stainburn@ringways.co.uk>
On Mon, 6 Jan 2003, Gary Stainburn wrote:
> create view turn_details as
> select t.*, d.sid as dsid, d.sname as dname,
> f.sid as fsid, f.sname as fname,
> (select sum(r.rmiles) as rmiles from rides r where r.rtid = tid)
> as rmiles
> from turns t
> left outer join staff d on t.tfitter = d.sid
> left outer join staff f on t.tccleaner = f.sid
> where r.rtid = t.tid
> order by tdate;
> ERROR: Relation 'r' does not exist
Do you really need the outer where r.rtid=t.tid? I would think that the
subselect where clause would already handle that for you.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: sszabo@megazone23.bigpanda.com, gary.stainburn@ringways.co.uk
Subject: Re: sub-select, view and sum()
In-Reply-To: <20030106102933.K47795-100000@megazone23.bigpanda.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox