Re: how to do this select?

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: how to do this select?
Date: 2009-02-19 07:33:10
Message-ID: 20090219073310.GB8766@a-kretschmer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Yi Zhao 2009-02-19 07:46:27 Re: how to do this select?
Previous Message Craig Ringer 2009-02-19 07:31:05 Re: how to do this select?