MySQL Forums
Forum List  »  Stored Procedures

Re: How to replace in syntax when calling stored procedure?
Posted by: Devart Team
Date: August 16, 2012 03:14AM

Change '%y%m%d' format to '%Y%m%d'. And remove GROUP BY clause, because query with GROUP BY clause can return more then one row.

CREATE FUNCTION NumOfTests(yr  VARCHAR(4), mth VARCHAR(2))
RETURNS INT(11)
BEGIN
  DECLARE number INT DEFAULT 0;

  SELECT
    COUNT(DISTINCT SN) INTO number
  FROM
    tester
  WHERE
    Date > STR_TO_DATE(CONCAT(yr, mth, '01'), '%Y%m%d') AND Date < STR_TO_DATE(CONCAT(yr, mth, '01'), '%Y%m%d') + INTERVAL 1 MONTH;

  RETURN (number);
END

Devart Company,
MySQL management tools
http://www.devart.com/dbforge/mysql/

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: How to replace in syntax when calling stored procedure?
1264
August 16, 2012 03:14AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.