create table history(response_date date, r_value bit);
insert into values('2023-03-18',1),('2023-03-19',NULL),
('2023-03-20',NULL),('2023-03-21',1),('2023-03-22',NULL),
('2023-03-23',0),('2023-03-24',0),('2023-03-25',NULL),
('2023-03-26',NULL),('2023-03-27',NULL),('2023-03-28',NULL);
I need only the starting record date of consecutive null values till the date from the table.
Expected result record date is:
2023-03-25
2条答案
按热度按时间4zcjmb1e1#
Find consecutive null values started date on date column:
You can do it using ROW_NUMBER() OVER PARTITION BY
r_value
as in this demo .Output :
t3irkdon2#