Received: from localhost (unknown [200.46.204.184]) by developer.postgresql.org (Postfix) with ESMTP id 2068A2E2B28 for ; Wed, 9 Apr 2008 03:15:56 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 73086-04 for ; Wed, 9 Apr 2008 03:15:45 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from lvs2.netcore.co.in (lvs5.netcore.co.in [202.162.240.5]) by developer.postgresql.org (Postfix) with ESMTP id ACCDA2E0084 for ; Wed, 9 Apr 2008 03:09:44 -0300 (ADT) Received: from uucp3.netcore.co.in (uucp3.netcore.co.in [202.162.229.13]) by lvs2.netcore.co.in (Postfix) with ESMTP id DF3BACF9AA; Wed, 9 Apr 2008 11:32:04 +0530 (IST) Received: from newuucp1.netcore.co.in (uucp1.netcore.co.in [202.162.229.12]) by uucp3.netcore.co.in (Postfix) with ESMTP id 03A5CAB590; Wed, 9 Apr 2008 11:32:04 +0530 (IST) Received: by newuucp1.netcore.co.in (Postfix, from userid 10) id D76CB2A1E2; Wed, 9 Apr 2008 11:32:04 +0530 (IST) Received: from [192.168.20.65] (unknown [192.168.20.65]) by ho.netcore.co.in (Postfix) with ESMTP id 87A6110069; Wed, 9 Apr 2008 11:30:19 +0530 (IST) Message-ID: <47FC5B73.1040300@netcore.co.in> Date: Wed, 09 Apr 2008 11:30:19 +0530 From: ashish User-Agent: Thunderbird 2.0.0.6 (X11/20070801) MIME-Version: 1.0 To: Volkan YAZICI CC: novice , pgsql-sql@postgresql.org Subject: Re: count question References: <87ej9fr3kh.fsf@alamut.mobiliz.com.tr> In-Reply-To: <87ej9fr3kh.fsf@alamut.mobiliz.com.tr> Content-Type: multipart/alternative; boundary="------------000000070801060401050905" MailScanner-NULL-Check: 1208325626.76496@PWz0bAgoQ9RRGgRJ2RW63Q X-MailServ-MailFilter-MailScanner-Information: Please contact the ISP for more information X-MailServ-MailFilter-MailScanner: Found to be clean X-MailScanner-From: ashish.karalkar@netcore.co.in X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200804/58 X-Sequence-Number: 30597 This is a multi-part message in MIME format. --------------000000070801060401050905 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Volkan YAZICI wrote: > On Wed, 9 Apr 2008, novice writes: > >> 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 >> > > Shouldn't this function be the responsitibility of client software, > instead of database? > > > Regards. > May be this will help you ashish=# select meter_id,no_of_bays,meter_id||'-'||generate_series(1,no_of_bays) from meter; meter_id | no_of_bays | ?column? ----------+------------+---------- 5397 | 2 | 5397-1 5397 | 2 | 5397-2 5409 | 3 | 5409-1 5409 | 3 | 5409-2 5409 | 3 | 5409-3 With Regards Ashish =================================================================== sms START NETCORE to 575758 to get updates on Netcore's enterprise products and services sms START MYTODAY to 09845398453 for more information on our mobile consumer services or go to http://www.mytodaysms.com =================================================================== --------------000000070801060401050905 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit Volkan YAZICI wrote:
On Wed, 9 Apr 2008, novice <user.postgresql@gmail.com> writes:
  
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
    

Shouldn't this function be the responsitibility of client software,
instead of database?


Regards.
  

May be this will help you


ashish=# select meter_id,no_of_bays,meter_id||'-'||generate_series(1,no_of_bays) from meter;
 meter_id | no_of_bays | ?column?
----------+------------+----------
     5397 |          2 | 5397-1
     5397 |          2 | 5397-2
     5409 |          3 | 5409-1
     5409 |          3 | 5409-2
     5409 |          3 | 5409-3

With Regards
Ashish

===================================================================

sms START NETCORE to 575758 to get updates on Netcore's enterprise
products and services

sms START MYTODAY to 09845398453 for more information on our mobile
consumer services or go to http://www.mytodaysms.com

===================================================================
--------------000000070801060401050905--