Re: [PATCH] distinct aggregates within a window function WIP

From: Andreas Karlsson <andreas(at)proxel(dot)se>
To: Eugen Konkov <kes-kes(at)yandex(dot)ru>, PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: [PATCH] distinct aggregates within a window function WIP
Date: 2020-04-21 15:17:00
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 4/21/20 5:06 PM, Eugen Konkov wrote:
> Hi. I read the thread.
> Probably this fiddle will be helpful for testing:
> I recently encountered a problem:
> Why Window-specific functions do not allow DISTINCT to be used within the function argument list?
> sum( DISTINCT order_cost ) OVER ( PARTITION BY invoice_id ORDER BY invoice_id, group_id RANGE unbound preceeding and unbound following )
> behavior is quite deterministic:
> ORDER BY will create peers in partition
> DISTINCT will get only one peer
> I resolve my problem via two subqueries, but it seems this logic may
> be applied to window functions (did not check this for other functions thought)

Sorry, I do not follow. What problem did you encounter?


In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2020-04-21 15:34:54 Re: More efficient RI checks - take 2
Previous Message Eugen Konkov 2020-04-21 15:06:11 [PATCH] distinct aggregates within a window function WIP