Re: DELETE with LIMIT (or my first hack)
От | Andrew Dunstan |
---|---|
Тема | Re: DELETE with LIMIT (or my first hack) |
Дата | |
Msg-id | 4CF47CAD.50107@dunslane.net обсуждение исходный текст |
Ответ на | Re: DELETE with LIMIT (or my first hack) (Robert Haas <robertmhaas@gmail.com>) |
Ответы |
Re: DELETE with LIMIT (or my first hack)
|
Список | pgsql-hackers |
<br /><br /> On 11/29/2010 10:19 PM, Robert Haas wrote: <blockquote cite="mid:AANLkTinsts6=TQD29J2WhQK37k58_i4jNVGsYn2c7xk5@mail.gmail.com"type="cite"><br /><pre wrap="">For example, supposewe're trying to govern an ancient Greek democracy: <a class="moz-txt-link-freetext" href="http://en.wikipedia.org/wiki/Ostracism">http://en.wikipedia.org/wiki/Ostracism</a> DELETE FROM residents_of_athens ORDER BY ostracism_votes DESC LIMIT 1; </pre></blockquote><br /> I'm not sure this is a very good example. Assuming there isn't a tie, I'd do it like this:<br /><br/><blockquote>DELETE FROM residents_of_athens <br /> WHERE ostracism_votes >= 6000 <br /> and ostracism_votes= <br /> (SELECT max(ostracism_votes) <br /> FROM residents_of_athens);<br /></blockquote><br /><prewrap="">I can't say I'd be excited by this feature. In quite a few years of writing SQL I don't recall ever wantingsuch a gadget. cheers andrew </pre><br />
В списке pgsql-hackers по дате отправления: