how to do this select?

Поиск
Список
Период
Сортировка
От Yi Zhao
Тема how to do this select?
Дата
Msg-id 1235024832.3155.12.camel@localhost.localdomain
обсуждение исходный текст
Ответ на PostgreSQL for a mission critical system  (Andrés Robinet <agrobinet@gmail.com>)
Ответы Re: how to do this select?  (Craig Ringer <craig@postnewspapers.com.au>)
Список pgsql-general
hi, all, I have a table in postgresql which have 2 columns like this:
a|b
------
X A
X A
Y A
D B
H B
E B
D B
P C
when I do select and order by, I got this:
 a | b
---+---
 X | A
 X | A
 Y | A
 D | B
 H | B
   | B
 D | B
 P | C

I want to get the only 2 rows(limit or random) if the column "b" have
the same value. so, the result of the above is
a | b
---+---
X | A
X | A
D | B
H | B
P | C

how to do that, thanks all!


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

Предыдущее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: Removing a corrupt database by hand
Следующее
От: "Sameer Mahajan"
Дата:
Сообщение: postgres wish list