CREATE TABLE NUM (
    SN INT,
    NUMB INT
);

-- Step 2: Insert sample data
INSERT INTO NUM (SN, NUMB) VALUES
(1, 4),
(2, 7),
(3, 4),
(4, 9),
(5, 9),
(6, 7),
(7, 9),
(8, 4);

with ct as (
select n1.sn,n1.numb,n2.numb as numb_2, n3.numb as numb_3 
    
    from num n1
    join num n2 on n1.sn+1=n2.sn
    join num n3 on n1.sn+2=n3.sn

    )
select distinct numb
    from ct
        where numb=numb_3 and numb<>numb_2;

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: