Re: how to do this select?

Поиск
Список
Период
Сортировка
От A. Kretschmer
Тема Re: how to do this select?
Дата
Msg-id 20090219073310.GB8766@a-kretschmer.de
обсуждение исходный текст
Ответ на Re: how to do this select?  (Yi Zhao <yi.zhao@alibaba-inc.com>)
Ответы Re: how to do this select?  (Yi Zhao <yi.zhao@alibaba-inc.com>)
Список pgsql-general
In response to Yi Zhao :
> thanks Ringer.
> my mean is that:
> I want less than 2 rows which have the same value of column "b"!
>
> for example, there is 3 columns have the same value "A",
>  X | A
>  X | A
>  Y | A
> I want my result have two of them.

I think, you are searching for DISTINCT:

test=# create table foo (a text, b text);
CREATE TABLE
test=*# copy foo from stdin;
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself.
>> a    a
>> a    a
>> b    a
>> \.
test=*# select distinct a,b from foo;
 a | b
---+---
 a | a
 b | a
(2 rows)


Please, no silly top-posting.

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?


Andreas
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net

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

Предыдущее
От: Craig Ringer
Дата:
Сообщение: Re: how to do this select?
Следующее
От: Yi Zhao
Дата:
Сообщение: Re: how to do this select?