title: ORACLE SQL ORA-24344 - counting attendance function error
body: <p>Hey guys I have a problem,
  I want to create a function in ORACLE which will count number of attendance (how many subject has enrolled one student). Could you give me a tip I don't know if my syntax is even okay?</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION num_of_attendance (id_student IN NUMBER)
  RETURN NUMBER
  IS total_number_of_attendance NUMBER DEFAULT 0;
  BEGIN 
      WITH attendance AS
      (
          SELECT id_student, code_course, COUNT(DISTINCT code_subject)
          FROM STUDENT NATURAL INNER JOIN attendance NATURAL INNER JOIN course NATURAL INNER JOIN course_subject NATURAL INNER JOIN subject
      );
      RETURN total_number_of_attendance;
  END;
  /
  </code></pre>