Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Sql > Re: count quest...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 5 Topic 3400 of 3717
Post > Topic >>

Re: count question

by rdeleonp@[EMAIL PROTECTED] Apr 8, 2008 at 10:34 PM

On 4/8/08, Craig Ringer <craig@[EMAIL PROTECTED]
> wrote:
> novice wrote:
>
> > 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
>
> Sure. One way, not necessarily a particularly clever or efficient way,
> is to do a join with:
>
> generate_series(1, (select max(no_of_bays) from meter)) as i
>
> and use a WHERE clause to select for `i <= no_of_bays'

You have a problem, and it's bad design.

A bad design leads to these types of kludges.

Consider re-engineering your schema.

In any case, good luck.

-- 
Sent via pgsql-sql mailing list (pgsql-sql@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
 




 5 Posts in Topic:
count question
user.postgresql@[EMAIL PR  2008-04-09 11:51:35 
Re: count question
craig@[EMAIL PROTECTED]   2008-04-09 10:11:39 
Re: count question
rdeleonp@[EMAIL PROTECTED  2008-04-08 22:34:22 
Re: count question
yazicivo@[EMAIL PROTECTED  2008-04-09 08:37:50 
Re: count question
ashish.karalkar@[EMAIL PR  2008-04-09 11:30:19 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Oct 13 6:55:37 CDT 2008.