Aniket Narvankar
This is one of the Interview Question Ask in one of MNC Company Interviewt bl1 Id Sal 1 1000 2 2000 3 3000 Output Asked Was Id Sal 1 1000 2 3000 3 6000 For fist row Sal Should be same,for second row sum of first and second and third row sum of first,second and third.
By Aniket Narvankar in SQL Language on Dec 16 2016
  • Sushobhit  Raman
    Nov, 2017 7

    select Id,sum(Sal) over(order by Id)AS SAL from @tbl

    • 1
  • Sushobhit  Raman
    Nov, 2017 7

    select Id,sum(Sal) over(order by Id)AS SAL from @tbl

    • 1
  • Aniket Narvankar
    Dec, 2016 16

    The query for above question:Select a.Id,(Case when a.Id <> 0 then(Select Sum(Sal) from tbl1 b where b.Id <= a.Id) end) as Sal from tbl1 a order by a.Id

    • 0