pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: novice <user.postgresql@gmail.com>
To: pgsql-sql@postgresql.org
Subject: populate value of column
Date: Wed, 8 Aug 2007 15:30:47 +1000
Message-ID: <ddcb1c340708072230pe7e096bx40fe3e8b348a69de@mail.gmail.com> (raw)

I have a table

CREATE TABLE meter
(
  meter_id integer NOT NULL,
  area_no integer NOT NULL,
  CONSTRAINT meter_pkey PRIMARY KEY (meter_id)
) ;

INSERT INTO meter(meter_id, no_of_bays) VALUES (1001, 4);
INSERT INTO meter(meter_id, no_of_bays) VALUES (1012, 6);

select meter_id, area_no from meter;

 meter_id | no_of_bays
----------+------------
     1001 |         4
     1012 |         6


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



view thread (5+ messages)  latest in thread

Message-ID: <ddcb1c340708072230pe7e096bx40fe3e8b348a69de@mail.gmail.com>
Permalink:  ../ddcb1c340708072230pe7e096bx40fe3e8b348a69de@mail.gmail.com/
Also on:    postgresql.org/message-id/ddcb1c340708072230pe7e096bx40fe3e8b348a69de@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: user.postgresql@gmail.com
  Subject: Re: populate value of column
  In-Reply-To: <ddcb1c340708072230pe7e096bx40fe3e8b348a69de@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox