Re: Group By aggregate string function

"David G. Johnston" <[email protected]> Thu, 21 Feb 2019 12:53:59 -0700
Newsgroups gmane.comp.db.postgresql.sql
Message-ID <CAKFQuwa9yvhJLcN2cj7u+eOHE0qfcFy__C32W5F9KtbpafuHeg@mail.gmail.com>
On Thu, Feb 21, 2019 at 12:02 PM Campbell, Lance <[email protected]> wrote:

> Expected Result:
>
> 1 lance admin
>
>
>
> Ignores the second record with lance in it because the first record
> contained admin.
>
>
> Ignoring <> Grouping

Grouping:
SELECT x, array_agg(DISTINCT y ORDER BY y)
FROM (VALUES ('a',1),('a',2),('b',1),('c',2)) vals (x,y)
GROUP BY x;

Ignoring:
SELECT DISTINCT ON (x) x, y
FROM (VALUES ('a',1),('a',2),('b',1),('c',2)) vals (x,y)
ORDER BY x, y;

David J.
image001.png (image/png, 2.5 KB) - not displayed