Re: aggregation question

From: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
To: Chris Withers <chris(at)simplistix(dot)co(dot)uk>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: aggregation question
Date: 2015-12-08 11:51:53
Message-ID: CAKJS1f-7HhYLcDm7vHQSAT2XwkmWXSEfBNE8F0nuYH5W5NEesg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 9 December 2015 at 00:44, Chris Withers <chris(at)simplistix(dot)co(dot)uk> wrote:

> Hi All,
>
> I hope this is quite a simple one...
>
> I have a fixtures table containing home_club and away_club, and I'd like
> to select the distinct list of clubs contained in all rows but in either
> the home_club or away_club columns.
>
> How would I do that?
>

Use UNION:

select home_club from fixtures UNION select away_club from fixtures;

--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Chris Withers 2015-12-08 12:21:46 Re: union/difference/intersection question
Previous Message Chris Withers 2015-12-08 11:44:23 aggregation question