次のクエリを試してみてください:
CREATE DEFINER=`root`@`localhost` FUNCTION `cal1`(z DATE , y DATE) RETURNS float
BEGIN
SET @c= (SELECT a.StudentName, (b.marks/a.marks) as difference from (select Date, StudentName, marks from studenthistory2015 WHERE Date=z) as a INNER JOIN (select Date, StudentName, marks from studenthistory2015 where Date=y) as b on a.date=z and b.date=y WHERE a.date = z and b.date = y and a.StudentName=b.StudentName
);
RETURN @c;
END
実行:
select student_history.cal1('2015-01-01', '2015-02-01'); しかし、実行後、Error #1241 Operand should contain 1 column(s) が表示されます
このクエリをどのように解決すればよいですか?