Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create or replace function medieBarbati
- return float
- AS
- suma float;
- counnt int;
- CURSOR cur_product
- IS
- SELECT
- *
- FROM
- pacienti;
- BEGIN
- suma :=0;
- counnt :=0;
- FOR pacient IN cur_product
- LOOP
- if pacient.sex=1
- then counnt := counnt + 1;
- end if;
- END LOOP;
- FOR pacient IN cur_product
- LOOP
- if pacient.sex=1 then
- suma := suma + (SYSDATE-pacient.data_nastere)/365;
- end if;
- END LOOP;
- DBMS_OUTPUT.PUT_LINE(suma);
- RETURN trunc(suma/counnt,3);
- END medieBarbati;
- /
- create or replace function medieFemei
- return float
- AS
- suma float;
- counnt int;
- CURSOR cur_product
- IS
- SELECT
- *
- FROM
- pacienti;
- BEGIN
- suma :=0;
- counnt :=0;
- FOR pacient IN cur_product
- LOOP
- if pacient.sex=2
- then counnt := counnt + 1;
- end if;
- END LOOP;
- FOR pacient IN cur_product
- LOOP
- if pacient.sex=2 then
- suma := suma + (SYSDATE-pacient.data_nastere)/365;
- end if;
- END LOOP;
- DBMS_OUTPUT.PUT_LINE(suma);
- RETURN trunc(suma/counnt,3);
- END medieFemei;
- /
- select medieBarbati from dual;
- select medieFemei from dual;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement