dumb question

From: Steve Clark <steve(dot)clark(at)netwolves(dot)com>
To: pgsql <pgsql-general(at)postgresql(dot)org>
Subject: dumb question
Date: 2016-06-02 16:56:14
Message-ID: 769c14bd-2a1d-b126-71dc-bf73e8395fe1@netwolves.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

--

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Steve Clark 2016-06-02 17:16:06 dumb question
Previous Message John R Pierce 2016-06-02 16:39:07 Re: Replication