Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id E42642E0054 for ; Tue, 8 Apr 2008 22:51:39 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 63564-04 for ; Tue, 8 Apr 2008 22:51:37 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from el-out-1112.google.com (el-out-1112.google.com [209.85.162.182]) by developer.postgresql.org (Postfix) with ESMTP id 5CF112E0038 for ; Tue, 8 Apr 2008 22:51:37 -0300 (ADT) Received: by el-out-1112.google.com with SMTP id z25so2054348ele.0 for ; Tue, 08 Apr 2008 18:51:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition:x-google-sender-auth; bh=8Q95pujr4dYX5WZ4EF8wevZ2VCbzmbcmJvZJoYr4JAM=; b=Rzvx/BGdfd6ccgOe+vWNvcKDVeqStj1ITFd+NIr7tP0FcXpp0Cxe0tUSsuXB0iIsEAxj7pTxhKbqt0zyQ3ih88F6+iJEAa1WmWcq6B6ZhfAMoJGm1HEtmLRBxvFABaTfUDMlwyitVDa2JaKbvWqff35ljFj++mXSJaEXvkKtsYA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition:x-google-sender-auth; b=pLHs94FLL1U4gzMIAWKqNAqP6IZagTKPsU7ffTY7ElWvtY06E6hS9XxYDJK54c28FLxvxr5ZtnUXVjphjqza1JzLQOcFV5Y11lYrBRorURJn9UWqQtw4dt0jMWtJ58rjqPm40NjLoPCOPE01diMzzLy6cZ7rxpr7xcixOKU5Czc= Received: by 10.114.106.1 with SMTP id e1mr1691366wac.95.1207705895602; Tue, 08 Apr 2008 18:51:35 -0700 (PDT) Received: by 10.114.88.11 with HTTP; Tue, 8 Apr 2008 18:51:35 -0700 (PDT) Message-ID: Date: Wed, 9 Apr 2008 11:51:35 +1000 From: novice To: pgsql-sql@postgresql.org Subject: count question MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Google-Sender-Auth: 90c6164b7874b3f2 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200804/54 X-Sequence-Number: 30593 i have a table CREATE TABLE meter ( meter_id integer NOT NULL, no_of_bays integer, CONSTRAINT meter_pkey PRIMARY KEY (meter_id) ) INSERT INTO meter( meter_id, no_of_bays) VALUES (5397, 2); INSERT INTO meter( meter_id, no_of_bays) VALUES (5409, 3); select meter_id, no_of_bays from meter; meter_id | no_of_bays ----------+------------ 5397 | 2 5409 | 3 Is it possible to write a query to produce: meter_id | no_of_bays | bay_id ----------+------------+----------- 5397 | 2 | 5397-01 5397 | 2 | 5397-02 5409 | 3 | 5409-01 5409 | 3 | 5409-02 5409 | 3 | 5409-03