<p>I have a table that looks like that:</p>

<p><img src="https://i.stack.imgur.com/R0TIr.jpg" alt="alt text"></p>

<p>The rows are sorted by CLNDR_DATE DESC.</p>

<p>I need to find a CLNDR_DATE that corresponds to the highlighted row, in other words:<br>
Find the topmost group of rows WHERE EFFECTIVE_DATE IS NOT NULL,
and return the CLNR_DATE of a last row of that group.</p>

<p>Normally I would open a cursor and cycle from top to bottom until I find a NULL in EFFECTIVE_DATE. Then I would know that the date I am looking for is CLNDR_DATE, obtained at the previous step.</p>

<p>However, I wonder if the same can be achieved with a single SQL?</p>

Warning: Not a DBA by any means. ;)
But, a quick, untested stab at it:
```
```
SELECT min(CLNDR_DATE) FROM [TABLE]
WHERE (EFFECTIVE_DATE IS NOT NULL)
  AND (CLNDR_DATE > (
    SELECT max(CLNDR_DATE) FROM [TABLE] WHERE EFFECTIVE_DATE IS NULL
  ))
```
```
Assuming you want the
first
CLNDR_DATE
with
EFFECTIVE_DATE after the
last without
.
If you want the
first with
after the
first without
, change the subquery to use min() instead of max().