ok, thanks, I will create a new message when I post next time. about my question, I think distinct can't solve my problem, because I want to get more than one rows. if there is more than (or equal) 2 (eg: 2, 3, 4, 100 ...)rows have the same value of column 'b' , I want to get only 2 rows. if lesse than 2, I want get all the result of them. ps: I' think, the *2* in my example is not appropriate, how about 10, 50? thanks. On Thu, 2009-02-19 at 08:33 +0100, A. Kretschmer wrote: > 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 > -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general