title: MySql Function Creation Error
body: <p>I write a function like the following. the purpose of this function is to return the place of a student by some specific exam in a branch.</p>
  
  <pre><code>DELIMITER $$    
  
  CREATE FUNCTION `getMerit`( branch VARCHAR(50), totalMark DECIMAL(19,2), comaSeparetedExamIds VARCHAR(200) ) RETURNS INT(11)
  BEGIN
      SET @comaSeparetedExamIds=comaSeparetedExamIds;
      SET @branch =branch;
      SET @marks=totalMark;
  
      SELECT @place=COUNT(*)+1
      FROM (
          SELECT SUM(m.marks) marks 
          FROM marksheet m, studentinfo s
          WHERE exam_id IN (@comaSeparetedExamIds)
              AND m.student_roll=s.roll_no
              AND s.branch LIKE CONCAT(@branch,'%')
          GROUP BY m.student_roll
      ) AS a
      WHERE a.marks&gt;@totalMark; 
  
      RETURN @place;
      END$$
  
  DELIMITER ;
  </code></pre>
  
  <p>But It shows me an error. the Error is </p>
  
  <blockquote>
    <p>Query : CREATE FUNCTION <code>getMerit</code>( branch varchar(50), totalMark
    DECIMAL(19,2), comaSeparetedExamIds varchar(200) ) RETURNS int(11)
    BEG... Error Code : 1415 Not allowed to return a result set from a
    function</p>
  </blockquote>
  
  <p>What mistake I made here, Can anyone please help me?</p>