Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id A36E99FB8A3 for ; Wed, 8 Aug 2007 02:50:31 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 13595-05 for ; Wed, 8 Aug 2007 02:50:27 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from wa-out-1112.google.com (wa-out-1112.google.com [209.85.146.176]) by postgresql.org (Postfix) with ESMTP id 093B79FB817 for ; Wed, 8 Aug 2007 02:50:26 -0300 (ADT) Received: by wa-out-1112.google.com with SMTP id k40so89394wah for ; Tue, 07 Aug 2007 22:50:26 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=DjP4I/55L47p9ss+PA5IhQOQjeebSx4Yw3Ff55fFoCl9ReLHXPfbcKhkyL1QSIErA2qGxMxKf78O1zfu4yY5vuVTmh98/nmcKdI49dvhI+YcL/bjACSZcW+moSZuzRqUJ+vG6K+IePo07R20bWsE0kb5XY5Z3Xgs8LATFWSVWn0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=PNGn771AoiMEeoXRefyFQPACtRyaV8Dev5FdTk0YKE24848OKUrkqaG0hIidgy8LqaExFvyUNMcn5kl/hG5P5ID3r0oCQSkfOhrQk06zqVq3ZXYHC8CxjOvKWXD7n19bgD9+dng5C7iZgTp/YD/4w6ToTEMTNj65LIqehxyAYCY= Received: by 10.114.153.18 with SMTP id a18mr786201wae.1186552225727; Tue, 07 Aug 2007 22:50:25 -0700 (PDT) Received: by 10.114.81.10 with HTTP; Tue, 7 Aug 2007 22:50:25 -0700 (PDT) Message-ID: Date: Wed, 8 Aug 2007 15:50:25 +1000 From: novice To: "Phillip Smith" Subject: Re: populate value of column Cc: pgsql-sql@postgresql.org In-Reply-To: <00ec01c7d97e$31c9bd80$9b0014ac@wbaus090> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <00ec01c7d97e$31c9bd80$9b0014ac@wbaus090> X-Google-Sender-Auth: 13ac88cea880d712 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/47 X-Sequence-Number: 28985 Thank you :-)) That's so quick! Apologies for the error on my DDL statement On 08/08/07, Phillip Smith wrote: > -----Original Message----- > From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] > On Behalf Of novice > Sent: Wednesday, 8 August 2007 15:31 > To: pgsql-sql@postgresql.org > Subject: [SQL] populate value of column > > > How can I generate the following result? > > > > meter_id | bay > > ----------+------------ > > 1001 | 01 > > 1001 | 02 > > 1001 | 03 > > 1001 | 04 > > 1012 | 01 > > 1012 | 02 > > 1012 | 03 > > 1012 | 04 > > 1012 | 05 > > 1012 | 06 > > I even tested this one too ;) > SELECT meter_id, > LPAD(GENERATE_SERIES(1,area_no),2,'0') > FROM meter; > > Works on 8.2.4 - you didn't say what version you were using. > > > *******************Confidentiality and Privilege Notice******************* > > The material contained in this message is privileged and confidential to > the addressee. If you are not the addressee indicated in this message or > responsible for delivery of the message to such person, you may not copy > or deliver this message to anyone, and you should destroy it and kindly > notify the sender by reply email. > > Information in this message that does not relate to the official business > of Weatherbeeta must be treated as neither given nor endorsed by Weatherbeeta. > Weatherbeeta, its employees, contractors or associates shall not be liable > for direct, indirect or consequential loss arising from transmission of this > message or any attachments > > THINK BEFORE YOU PRINT - Save paper if you don't really need to print this > e-mail. > > ---------------------------(end of broadcast)--------------------------- > TIP 9: In versions below 8.0, the planner will ignore your desire to > choose an index scan if your joining column's datatypes do not > match >