Search Postgresql Archives

Re: string_agg distinct order by

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Markhof, Ingolf" <ingolf.markhof@xxxxxxxxxxxxxx> writes:
> I am looking for something like
> string_agg(distinct col_x order by col_y)

> Unfortunately, you can either have the distinct, but then the order by
> needs to be identical to what's aggregated, or you can have the order be
> determined by another column. Not both...

The reason for that restriction is that the case you propose is
ill-defined.  If we combine rows with the same col_x, which row's
value of col_y is to be used to sort the merged row?  I think once
you answer that question, a suitable query will suggest itself.

			regards, tom lane





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux