Re: a bit confused about distinct() function

From: "Tena Sakai" <tsakai(at)gallo(dot)ucsf(dot)edu>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: a bit confused about distinct() function
Date: 2009-03-29 18:03:08
Message-ID: FE44E0D7EAD2ED4BB2165071DB8E328C04E84A53@egcrc-ex01.egcrc.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Many thanks, Tom.

Regards,

Tena Sakai
tsakai(at)gallo(dot)ucsf(dot)edu

-----Original Message-----
From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
Sent: Sun 3/29/2009 10:49 AM
To: Tena Sakai
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] a bit confused about distinct() function

"Tena Sakai" <tsakai(at)gallo(dot)ucsf(dot)edu> writes:
> I am a bit confused about distinct() function.

Your confusion is in thinking that DISTINCT is a function. It is not;
it's just a keyword that modifies SELECT. Write

select distinct subjectid, markerid, allele1id, allele2id
from tsakai.mygenotype2
...

The other syntax was being read as an implicit row constructor, like

select distinct row(subjectid, markerid, allele1id, allele2id)

which actually will work in PG 8.4, but does not in existing releases;
and you likely wouldn't like the output format anyway, since it would
just be one composite column.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Mario Splivalo 2009-03-30 08:41:09 xpath_table, or something similair?
Previous Message Tena Sakai 2009-03-29 18:02:33 Re: a bit confused about distinct() function