declare
i int:=1;
j int:=0;
begin
while i<=100
loop
if mod(i,3)=0
then
j:=j+i;
i:=i+1;
else
i:=i+1;
end if;
end loop;
Dbms_Output.Put_Line(j);
end;
select sum(
case when mod(t.rnum,3) = 0 then
t.rnum
else 0 end
) as total_sum
from
(
SELECT rownum rnum
FROM ALL_OBJECTS
WHERE ROWNUM <= 100
) t
;
create or replace procedure SumDataWhichCanDivideByThree as i_sumtotal number; i_ind number;begin for i in 1..100 loop if mod(i,3) =0 then i_sumtotal := i_sumtotal + i; end if; end loop;end;