SHARE
TWEET

Untitled

a guest Nov 15th, 2017 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE or REPLACE PROCEDURE RankGPA
  2. IS
  3.   vSnum   student.snum%type;
  4.   vSname  student.sname%type;
  5.   vGPA    student.GPA%type;
  6.   vMajor  student.major%type;
  7.   CURSOR rankGPA_cursor IS
  8.     SELECT s1.snum, s1.sname, s1.gpa, count( s2.gpa ) + 1 as rank, s1.major
  9.     FROM students s1
  10.     LEFT JOIN students s1
  11.     ON s1.GPA < s2.GPA
  12.     GROUP BY s1.snum, s1.sname, s1.gpa, s1.Major
  13.     ORDER BY 4;
  14. BEGIN
  15.   OPEN rankGPA_cursor;
  16.   FETCH rankGPA_cursor INTO vSnum, vSname, vGPA, vMajor;
  17. END;
RAW Paste Data
Top