我只是尝试以下查询:
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
执行 :
选择 student_history.cal1('2015-01-01', '2015-02-01'); 但执行后,它显示错误 #1241 操作数应包含 1 列
我应该如何解决这个查询?