Thats return me 0. Why? i need som like this 1/8 + 1/7 + 1/6....1/m Srry for my code, im learning sql.
delimiter // drop function if exists divide; create function divide(m int) returns decimal(30,3) deterministic begin declare m int; declare n decimal(30,3) default 0; declare x decimal(30,3) default 0; while m>=1 do set n=n+x; select 1/m into x; set m=m-1; end while; return n; end;// delimiter ; select divide(8);
Thanks you all, the solution was that i declared two times m.
1.4m articles
1.4m replys
5 comments
56.9k users