Re: BUG #16510: Count Distinct with non distinct column incombination with string constants throws error - Mailing list pgsql-bugs

From Daniel Gustafsson
Subject Re: BUG #16510: Count Distinct with non distinct column incombination with string constants throws error
Date
Msg-id 5CF2CF6C-8951-4CA1-980C-94F369B7EE86@yesql.se
Whole thread Raw
In response to BUG #16510: Count Distinct with non distinct column in combination with string constants throws error  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #16510: Count Distinct with non distinct column in combination with string constants throws error
List pgsql-bugs
> On 25 Jun 2020, at 15:02, PG Bug reporting form <noreply@postgresql.org> wrote:

> SELECT
> COUNT( DISTINCT (testtable.column2, 'blub') )
> FROM
> public.testtable;

PostgreSQL doesn't know which datatype you expect 'blub' to be, as it isn't
related to the testtable relation in your query.  If you cast to the datatype
of your choice you will get the expected result.

postgres=# SELECT COUNT(DISTINCT(testtable.column2, 'blub')) FROM public.testtable;
ERROR:  could not identify a comparison function for type unknown
postgres=# SELECT COUNT(DISTINCT(testtable.column2, 'blub'::varchar)) FROM public.testtable;
 count
-------
     1
(1 row)

cheers ./daniel


pgsql-bugs by date:

Previous
From: Axel Zellner
Date:
Subject: Bug: Postgresql with Postgis: Different result in coordinateconversion NAV4 <=> WGS84 in Linux and Windows
Next
From: Pierre Mantha
Date:
Subject: Re: BUG #16509: Unable to change from 32 bit to 64 bit