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: Different t...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 5 Topic 3522 of 3661
Post > Topic >>

Re: Different type of query

by scrawford@[EMAIL PROTECTED] (Steve Crawford) Jun 11, 2008 at 12:01 PM

> I would like to have multiple values nutrient_no:
> ndb_no | nutrient_no | nutrient_value
> --------+-------------+----------------
> 13473 |         203 |          24.18
> 13473 |         204 |          15.93
> 13473 |         205 |              0
> 13473 |         207 |            1.1
> 13473 |         208 |            247
> 13473 |         221 |              0
>
> I'm thinking:
> select nutrient_no, nutrient_value from nutrient_data where ndb_no = 
> 13473 and (nutrient_no = '203' or nutrient_no = '204' or nutrient_no = 
> 208);
>
Depending on what you are trying to achieve:

Particular ndb_no and multiple nutrient_no, note that output of ndb_no 
is superfluous as it is always the same:
select nutrient_no, nutrient_value from nutrient_data where ndb_no = 
13473 and nutrient_no in ('203', '204','208');

Size limited list (say top 5 nutrient values) for a given ndb_no:
select nutrient_no,nutrient_value from nutrient_data where ndb_no = 
13473 order by nutrient_value limit 5;

Cheers,
Steve


-- 
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:
Different type of query
postgres@[EMAIL PROTECTED  2008-06-11 13:27:45 
Re: Different type of query
scrawford@[EMAIL PROTECTE  2008-06-11 11:27:36 
Re: Different type of query
postgres@[EMAIL PROTECTED  2008-06-11 14:41:48 
Re: Different type of query
scrawford@[EMAIL PROTECTE  2008-06-11 12:01:29 
Tsearch
postgres@[EMAIL PROTECTED  2008-06-12 08:47:44 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan12V112 Sat Sep 6 15:40:21 CDT 2008.