clear markdown compare help best fiddles feedback dbanow.uk
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 2555464 fiddles created (37475 in the last week).

CREATE TABLE T (P INT PRIMARY KEY, V INT NOT NULL) --INSERT INTO T VALUES (1,0),(2,0),(3,0),(4,0) INSERT INTO T VALUES (1,43),(2,48),(3,48),(4,48),(5,52),(6,50),(7,48),(8,50) --INSERT INTO T SELECT ROW_NUMBER() OVER (ORDER BY (SELECT 0)), value FROM STRING_SPLIT('86 88 84 81 83 79 74 76 72 69 71 67 62 64 60 57 59 57 56 55',' ') --INSERT INTO T SELECT ROW_NUMBER() OVER (ORDER BY (SELECT 0)), value FROM STRING_SPLIT('82 79 78 76 78 76 74 73 70 67 66 64 66 64 62 61',' ') SELECT MAX(S)-MIN(S)+1FROM(SELECT*,SUM(ISNULL(X,0))OVER(ORDER BY P)S FROM(SELECT*,SIGN(V-LAG(V)OVER(ORDER BY P))X FROM T)A)B
(No column name)
3
 hidden batch(es)