Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create or replace function percent_passed_works(tutor number)
- return number
- is all_works number;
- passed_works number;
- begin
- select count(grade)
- into all_works
- from grades
- where tutor_id = tutor;
- select count(grade)
- into passed_works
- from grades
- where grade > 60
- and tutor_id = tutor;
- return (passed_works / all_works ) * 100;
- end;
- select distinct u.name, concat(percent_passed_works(g.tutor_id), '%') as "pass works"
- from grades g, user_web u, solution s, task t
- where s.id = g.solution_id
- and g.tutor_id = u.id
Advertisement
RAW Paste Data
Copied
Advertisement