Re: dumb question
От
Dann Corbit
Тема
Re: dumb question
Дата
Msg-id
87F42982BF2B434F831FCEF4C45FC33EA975CD8D@EXCHANGE.corporate.connx.com
Ответ на
dumb question (Steve Clark)
Список
Дерево обсуждения
dumb question Steve Clark <steve.clark@netwolves.com>
Re: dumb question Dann Corbit <DCorbit@connx.com>
Re: dumb question Dann Corbit <DCorbit@connx.com>
Re: dumb question "David G. Johnston" <david.g.johnston@gmail.com>
Re: dumb question Steve Clark <steve.clark@netwolves.com>
This is your request, translated directly into SQL select max(id) from sometable where sts=0 and ref_id IS NULL Looking at your sample, it seems that sts is always 1 when ref_id exists, so it may possibly simplify to: select max(id) from sometable where sts=0 -----Original Message----- From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Steve Clark Sent: Thursday, June 2, 2016 9:56 AM To: pgsql Subject: [GENERAL] dumb question Hi List, I am a noob trying to do something that seems like it should be easy but I can't figure it out. I have a table like so: id | ref_id | sts ------------------ 1 | | 0 2 | 1 | 1 3 | | 0 4 | | 0 5 | 4 | 1 6 | | 0 7 | 6 | 1 I want to find the max(id) whose sts is 0 but whose id is not referenced by ref_id. so the answer would be id=3. Thanks for any pointers, Steve -- -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
В списке pgsql-general по дате отправления