Advertisement
Maks140888

Untitled

May 27th, 2022
736
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. create or replace function percent_passed_works(tutor number)
  2. return number
  3. is all_works number;
  4.    passed_works number;
  5. begin
  6.     select count(grade)
  7.     into all_works
  8.     from grades
  9.     where tutor_id = tutor;
  10.    
  11.     select count(grade)
  12.     into passed_works
  13.     from grades
  14.     where grade > 60
  15.         and tutor_id = tutor;
  16.  
  17.     return (passed_works / all_works ) * 100;
  18. end;
  19.  
  20. select distinct u.name, concat(percent_passed_works(g.tutor_id), '%') as "pass works"
  21. from grades g, user_web u, solution s, task t
  22. where s.id = g.solution_id
  23. and g.tutor_id = u.id
  24.  
Advertisement
RAW Paste Data Copied
Advertisement