From: | Jochem van Dieten <jochemd(at)oli(dot)tudelft(dot)nl> |
---|---|
To: | Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: IN vs EXIIST |
Date: | 2002-09-19 10:59:55 |
Message-ID: | 1032433195.3d89ae2b96ff5@webmail.oli.tudelft.nl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Quoting Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp>:
>
> The reason being that key1 is not a primary key (key1, key2 is the
> primary key). i.e. I have a table like this
>
> key1 key2 x
> ------------------
> a 1 t
> a 2 t
> a 3 f
> b 1 t
> b 2 t
> b 3 t
> c 3 t
> c 4 f
>
> So basically I want key1 values for which all the X's are true.
SELECT key1, Min(CASE WHEN x THEN 1 ELSE 0 END) AS isTrue
FROM table
GROUP BY key1
HAVING isTrue = 1
> Or is my table schema wrong?
I generally don't design tables with composite keys. I find it to
complicated in many operations. But on occasion I have seen them being
used by others very efficiently.
Jochem
From | Date | Subject | |
---|---|---|---|
Next Message | Jean-Christian Imbeault | 2002-09-19 11:04:53 | Re: IN vs EXIIST |
Previous Message | Jean-Christian Imbeault | 2002-09-19 10:41:20 | Re: IN vs EXIIST |