Re: Different type of query

Поиск
Список
Период
Сортировка
От Steve Crawford
Тема Re: Different type of query
Дата
Msg-id 48502109.4090300@pinpointresearch.com
обсуждение исходный текст
Ответ на Re: Different type of query  (PostgreSQL Admin <postgres@productivitymedia.com>)
Ответы Tsearch  (PostgreSQL Admin <postgres@productivitymedia.com>)
Список pgsql-sql
> 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



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

Предыдущее
От: PostgreSQL Admin
Дата:
Сообщение: Re: Different type of query
Следующее
От: PostgreSQL Admin
Дата:
Сообщение: Tsearch