Skip site navigation (1) Skip section navigation (2)

count question

From: novice <user(dot)postgresql(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: count question
Date: 2008-04-09 01:51:35
Message-ID: ddcb1c340804081851y245f4776g9de74b5715e3a3e@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-sql
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

Responses

pgsql-sql by date

Next:From: Craig RingerDate: 2008-04-09 02:11:39
Subject: Re: count question
Previous:From: Tk421Date: 2008-04-08 17:39:38
Subject: Re: Pattern Matchig

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group