• with t1 as (select row_number() over (order by quote_date) n

    ,quote_date

    ,close_price

    from #google_stock)

    select a.n

    ,a.quote_date

    ,a.close_price

    ,CAST(null as decimal(8,2)) [sma]

    --add the close_price from 20 row prior to this one

    ,CAST(b.close_price as decimal(8,2)) [20_day_old_close]

    into #mod_goog_data

    from t1 a

    left join t1 b

    on a.n - 20 = b.n

    i keep having issue entering this into SQLserver... is this oracle statement? keep saying Msg 156, Level 15, State 1, Line 43

    Incorrect syntax near the keyword 'as'.