试试这个
drop table if exists #have;
CREATE TABLE #have
(
ID [INT]
, Status [VarChar](8)
);
insert into #have
values
(1 , 'P')
, (2 , 'F')
, (3 , 'F')
, (4 , 'P')
, (5 , 'P')
, (10, 'F')
, (22, 'F')
;
with cte as
(
select *
, lag(Status) over (order by ID) as prev
from #have
)
select ID, Status
from cte
where Status = 'F' and prev = 'P'
;