| From: | Louis-David Mitterrand <vindex+lists-pgsql-sql(at)apartia(dot)org> |
|---|---|
| To: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: exclusion query |
| Date: | 2008-09-23 08:18:30 |
| Message-ID: | 20080923081830.GA17997@apartia.fr |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
On Mon, Sep 22, 2008 at 09:39:08AM -0700, Mark Roberts wrote:
>
> Taking your second email into account, I came up with:
>
> select distinct pt.type_fr
> from person_to_event pte
> inner join person_type using (id_person_type)
> where id_person_type in (
> select id_person_type
> from person_to_event pte
> inner join event using (id_event)
> inner join event_type using (id_event_type)
> where type_fr = 'theatre'
> ) and id_person_type not in (
> select id_person_type
> from person_to_event
> where id_event = 219
> )
>
> I feel like there's a solution involving group by tugging at the back of
> my mind, but I can't quite put my finger on it. Sorry if this isn't
> quite what you're asking for.
Hi,
That works very nicely (with minor adaptations).
I also had that solution-without-a-subselect in the back of my mind but
this does the job just fine!
Cheers,
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Osvaldo Kussama | 2008-09-23 15:57:31 | Resp.: Multi-line text fields |
| Previous Message | Craig Ringer | 2008-09-23 04:27:25 | Re: Special grouping on sorted data. |