Different type of query

Поиск
Список
Период
Сортировка
От PostgreSQL Admin
Тема Different type of query
Дата
Msg-id 48500B11.80806@productivitymedia.com
обсуждение исходный текст
Ответ на Re: Check before INSERT INTO  (Gregory Stark <stark@enterprisedb.com>)
Ответы Re: Different type of query  (Steve Crawford <scrawford@pinpointresearch.com>)
Список pgsql-sql
I have a table like this:

usda=# \d nutrient_data           Table "public.nutrient_data"    Column      |         Type          | Modifiers
-----------------+-----------------------+-----------ndb_no          | integer               | not nullnutrient_no
|integer               | not nullnutrient_value  | double precision      | not nulldata_points     | double precision
  | not nullstd_error       | double precision      |src_cd          | integer               | not nullderivation_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 |
013473 |         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 |
013473 |         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


В списке pgsql-sql по дате отправления:

Предыдущее
От: "A. Kretschmer"
Дата:
Сообщение: Re: Update and trigger
Следующее
От: Steve Crawford
Дата:
Сообщение: Re: Different type of query