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 > Different type ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 5 Topic 3522 of 3799
Post > Topic >>

Different type of query

by postgres@[EMAIL PROTECTED] (PostgreSQL Admin) Jun 11, 2008 at 01:27 PM

I have a table like this:

usda=# \d nutrient_data
            Table "public.nutrient_data"
     Column      |         Type          | Modifiers
-----------------+-----------------------+-----------
 ndb_no          | integer               | not null
 nutrient_no     | integer               | not null
 nutrient_value  | double precision      | not null
 data_points     | double precision      | not null
 std_error       | double precision      |
 src_cd          | integer               | not null
 derivation_code | character varying(5)  |
 ref_ndb_no      | integer               |
 add_nutr_mark   | character varying(2)  |
 num_studies     | integer               |
 min             | double precision      |
 max             | double precision      |
 df              | numeric               |
 low_eb          | double precision      |
 up_eb           | double precision      |
 stat_cmt        | character varying(15) |
 cc              | character varying(5)  |
Indexes:
    "nutrient_data_pkey" PRIMARY KEY, btree (ndb_no, nutrient_no)
Foreign-key constraints:
    "nutrient_data_derivation_code_fkey" FOREIGN KEY (derivation_code) 
REFERENCES derivation_code(derivation_code) ON UPDATE CASCADE ON DELETE 
CASCADE
    "nutrient_data_ndb_no_fkey" FOREIGN KEY (ndb_no) REFERENCES 
food_description(ndb_no) ON UPDATE CASCADE ON DELETE CASCADE
    "nutrient_data_nutrient_no_fkey" FOREIGN KEY (nutrient_no) 
REFERENCES nutrient_definitions(nutrient_no) ON UPDATE CASCADE ON DELETE 
CASCADE
    "nutrient_data_src_cd_fkey" FOREIGN KEY (src_cd) REFERENCES 
source_code(src_cd) ON UPDATE CASCADE ON DELETE CASCADE



when I run this query:
 select ndb_no, nutrient_no, nutrient_value from nutrient_data where 
ndb_no = 13473;

it produces:
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
  13473 |         255 |          57.78
  13473 |         262 |              0
  13473 |         263 |              0
  13473 |         268 |           1033
  13473 |         269 |              0
  13473 |         291 |              0
  13473 |         301 |              5
  13473 |         303 |           3.35
  13473 |         304 |             24
  13473 |         305 |            199
  13473 |         306 |            302
  13473 |         307 |             67
  13473 |         309 |           4.67
  13473 |         312 |          0.131
  13473 |         315 |          0.015
  13473 |         317 |           10.9
  13473 |         318 |              0
  13473 |         319 |              0
  13473 |         320 |              0
  13473 |         321 |              0
  13473 |         322 |              0
  13473 |         323 |           0.18
  13473 |         334 |              0
  13473 |         337 |              0
  13473 |         338 |              0
  13473 |         401 |              0
  13473 |         404 |          0.101


I want only certain nutrient_no (say 8 of them) and the nutrient values 
by ndb_no.

how would I write that query.  BIG THANKS in advance as I'm lost on this 
one.

J

-- 
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 Tue Dec 2 21:34:58 CST 2008.