if you are interested to contribute your LAB PROGRAM Please send mail to jkumaron@gmail.com

Simple sql sum of series program | To find the sum of the series in sql program

To find the sum of series

Start the program.
Get the number of terms n.
Start the loop.
Compute the sum.
Increment the sum.
Exit the loop.
Output the sum.
Stop the program.

SQL> set serveroutput on
SQL> declare
2 n number(3):=&n;
3 i number(3):=1;
4 x number(3):=0;
5 begin
6 loop
7 x:=x+i;
8 exit when i=n;
9 i:=i+1;
10 end loop;
11 dbms_output.put_line('sum='x);
12 end;
13 /

Related post