Re: Can any_value be used like first_value in an aggregate?

2024-06-27 Thread Bruno Wolff III
On Wed, Jun 26, 2024 at 09:50:59 +0200, Laurenz Albe wrote: On Tue, 2024-06-25 at 14:11 -0500, Bruno Wolff III wrote: The actual use case is a set of tripplets returned from a query, where I want on row for each distinct value in the first column, paired with the value in the second column,

Re: Can any_value be used like first_value in an aggregate?

2024-06-26 Thread Laurenz Albe
On Tue, 2024-06-25 at 14:11 -0500, Bruno Wolff III wrote: > The actual > use case is a set of tripplets returned from a query, where I want on > row for each distinct value in the first column, paired with the value > in the second column, for which the third column is the largest. The >

Re: Can any_value be used like first_value in an aggregate?

2024-06-25 Thread Bruno Wolff III
On Tue, Jun 25, 2024 at 13:08:45 -0400, Tom Lane wrote: Not really. It will work that way in simple cases, but I think the behavior stops being predictable if the input gets large enough to induce the planner to use parallel aggregation. In any case, the example shown isn't amazingly

Re: Can any_value be used like first_value in an aggregate?

2024-06-25 Thread Tom Lane
Bruno Wolff III writes: > For example, is output of 10 guaranteed in the following: > bruno=> select any_value(x order by x desc) from generate_series(1,10) as x; > any_value > --- > 10 > (1 row) Not really. It will work that way in simple cases, but I think the behavior stops

Can any_value be used like first_value in an aggregate?

2024-06-25 Thread Bruno Wolff III
For example, is output of 10 guaranteed in the following: bruno=> select any_value(x order by x desc) from generate_series(1,10) as x; any_value --- 10 (1 row) The use case is that I want to return a value of one column that is paired with the maximum value of another column in