Re: sub-select, view and sum()

From: Gary Stainburn <gary(dot)stainburn(at)ringways(dot)co(dot)uk>
To: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: sub-select, view and sum()
Date: 2003-01-06 22:29:47
Message-ID: 200301062229.47578.gary.stainburn@ringways.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Monday 06 January 2003 6:31 pm, Stephan Szabo wrote:
> 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.

Hi Stephan,

Thanks for that. That was the problem. I'd left it after trying to use a
normal join in an earlier attempt.

Gary
--
Gary Stainburn

This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Rowell 2003-01-07 03:58:35 to_date confusion
Previous Message Stephan Szabo 2003-01-06 18:31:29 Re: sub-select, view and sum()