pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gary Stainburn <gary.stainburn@ringways.co.uk>
To: PostgreSQL-sql <pgsql-sql@postgresql.org>
Subject: Re: sub-sel/group problem
Date: Mon, 11 Aug 2003 11:38:43 +0100
Message-ID: <200308111138.43196.gary.stainburn@ringways.co.uk> (raw)
In-Reply-To: <200308111124.07832.gary.stainburn@ringways.co.uk>
References: <200308111124.07832.gary.stainburn@ringways.co.uk>

On Monday 11 August 2003 11:24 am, Gary Stainburn wrote:
> Hi folks,
>
> I don;t know if it's cos it's Monday or what, but I can't see what's wrong
> here.
>
> I've got two tables, turns which holds a turn number, a task, and where
> appropriate a link to a loco.  The select below works but only shows those
> tasks where a loco is involved.:
>
[snip]

Having re-read my email and had another go, I've opted for the sub-select 
approach, and come up with:

select rtid, concat(task) from 
    (select  rtid, 
     case when r.rlid > 0 then
       r.rcid::text || ' on ' || l.lnumber::text
     else
       r.rcid::text
     end as task
    from rides r
     left outer join loco_dets l on r.rlid = l.lid) r
    group by rtid
    order by rtid
;

Can anyone see any problems with this, or come up with a better approach?
-- 
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     




view thread (5+ messages)  latest in thread

Message-ID: <200308111138.43196.gary.stainburn@ringways.co.uk>
Permalink:  ../200308111138.43196.gary.stainburn@ringways.co.uk/
Also on:    postgresql.org/message-id/200308111138.43196.gary.stainburn@ringways.co.uk

 · 

reply

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: gary.stainburn@ringways.co.uk
  Subject: Re: sub-sel/group problem
  In-Reply-To: <200308111138.43196.gary.stainburn@ringways.co.uk>

* 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