Re: sub-select, view and sum() - Mailing list pgsql-sql

From Stephan Szabo
Subject Re: sub-select, view and sum()
Date
Msg-id 20030106102933.K47795-100000@megazone23.bigpanda.com
Whole thread Raw
In response to sub-select, view and sum()  (Gary Stainburn <gary.stainburn@ringways.co.uk>)
Responses Re: sub-select, view and sum()  (Gary Stainburn <gary.stainburn@ringways.co.uk>)
List pgsql-sql
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.



pgsql-sql by date:

Previous
From: Robert Treat
Date:
Subject: Re: Sorry, to many clients already
Next
From: Gary Stainburn
Date:
Subject: Re: sub-select, view and sum()