X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 01504D1C4E6 for ; Mon, 11 Aug 2003 10:38:40 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 77608-06 for ; Mon, 11 Aug 2003 07:37:12 -0300 (ADT) Received: from stan.ringways.co.uk (hub.ringways.co.uk [213.38.87.130]) by svr1.postgresql.org (Postfix) with ESMTP id 05251D1C47A for ; Mon, 11 Aug 2003 07:38:29 -0300 (ADT) Received: from gary.ringways.co.uk ([10.1.1.2]) by stan.ringways.co.uk with esmtp (Exim 3.22 #1) id 19mA31-0004zT-00 for pgsql-sql@postgresql.org; Mon, 11 Aug 2003 11:37:07 +0100 Content-Type: text/plain; charset="iso-8859-1" From: Gary Stainburn Organization: Ringways Garages Ltd To: PostgreSQL-sql Subject: Re: sub-sel/group problem Date: Mon, 11 Aug 2003 11:38:43 +0100 User-Agent: KMail/1.4.3 References: <200308111124.07832.gary.stainburn@ringways.co.uk> In-Reply-To: <200308111124.07832.gary.stainburn@ringways.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200308111138.43196.gary.stainburn@ringways.co.uk> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/95 X-Sequence-Number: 14711 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