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: count question
Date: Wed, 9 Apr 2008 11:51:35 +1000
Message-ID: <ddcb1c340804081851y245f4776g9de74b5715e3a3e@mail.gmail.com> (raw)

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



view thread (9+ messages)  latest in thread

Message-ID: <ddcb1c340804081851y245f4776g9de74b5715e3a3e@mail.gmail.com>
Permalink:  ../ddcb1c340804081851y245f4776g9de74b5715e3a3e@mail.gmail.com/
Also on:    postgresql.org/message-id/ddcb1c340804081851y245f4776g9de74b5715e3a3e@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: count question
  In-Reply-To: <ddcb1c340804081851y245f4776g9de74b5715e3a3e@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