Re: More on unique vs distinct

From: Casey Duncan <casey(at)pandora(dot)com>
To: stafford(at)marine(dot)rutgers(dot)edu
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: More on unique vs distinct
Date: 2006-11-20 22:58:23
Message-ID: C3274B8A-7CDE-4B1C-B982-C7B51348ECA3@pandora.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Nov 20, 2006, at 12:27 PM, Wm.A.Stafford wrote:

> I guess I should have been a bit more specific. Here is an example
> of the type of query I'm finding in the Oracle app and the results
> of my attempt to find a PostgreSQL equivalent.
>
> select count(unique 'source_id') from obis_sources;
> pgAdmin III query responds:
> ERROR: syntax error at or near "'source_id'" at character 23
>
> select count(distinct 'source_id') from obis_sources;
> pgAdmin III query responds:
> ERROR: could not identify an equality operator for type "unknown"

The single quotes are confusing things here, it treats 'source_id' as
a literal string instead of a column name. Try it without the quotes:

select count(distinct source_id) from obis_sources;

hth,

-Casey

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rafal Pietrak 2006-11-20 22:59:42 Re: functions: stable/volatile
Previous Message Rodrigo Gonzalez 2006-11-20 22:46:21 Re: More on unique vs distinct