Re: IN vs EXIIST
| От | Jochem van Dieten |
|---|---|
| Тема | Re: IN vs EXIIST |
| Дата | |
| Msg-id | 1032433195.3d89ae2b96ff5@webmail.oli.tudelft.nl обсуждение исходный текст |
| Ответ на | IN vs EXIIST (Jean-Christian Imbeault <jc@mega-bucks.co.jp>) |
| Список | pgsql-general |
Quoting Jean-Christian Imbeault <jc@mega-bucks.co.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
В списке pgsql-general по дате отправления: