Re: dumb question
От | Steve Crawford |
---|---|
Тема | Re: dumb question |
Дата | |
Msg-id | CAEfWYyxZ78N1o-D66OoYvFYMHOyq5iEA2o-nTdv1m=UFGc4-dw@mail.gmail.com обсуждение исходный текст |
Ответ на | dumb question (Steve Clark <steve.clark@netwolves.com>) |
Ответы |
Re: dumb question
|
Список | pgsql-general |
Something like:
That assumes that ref_id is null. It would help to see your table structure and the query you tried that doesn't work. If ref_id is actually a character string then you might need ref_id='' or coalesce(ref_id,'')='' if it can be null or empty string.
Cheers,
Steve
On Thu, Jun 2, 2016 at 10:16 AM, Steve Clark <steve.clark@netwolves.com> wrote:
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 по дате отправления: