Re: count question

From: ashish <ashish(dot)karalkar(at)netcore(dot)co(dot)in>
To: Volkan YAZICI <yazicivo(at)ttmail(dot)com>
Cc: novice <user(dot)postgresql(at)gmail(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: count question
Date: 2008-04-09 06:00:19
Message-ID: 47FC5B73.1040300@netcore.co.in
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Volkan YAZICI wrote:
> On Wed, 9 Apr 2008, novice <user(dot)postgresql(at)gmail(dot)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

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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Sabin Coanda 2008-04-09 07:06:24 Re: undefined relations in pg_locks
Previous Message Volkan YAZICI 2008-04-09 05:37:50 Re: count question