我一直收到错误ORA-01422:确切的提取返回超过请求的行数。 ORA-06512:at" CM420A07.ZIP_CODE_SALES_WINNER",第6行。我无法确切地知道出了什么问题。
CREATE OR REPLACE FUNCTION ZIP_CODE_SALES_WINNER
RETURN VARCHAR
IS
zipWinner VARCHAR2(5);
BEGIN
SELECT C.zip_code INTO zipWinner
FROM SALE S JOIN CUSTOMER C
ON S.cust_ID = C.cust_ID
GROUP BY C.zip_code
HAVING COUNT(*) = (
SELECT MAX(COUNT(*))
FROM SALE S JOIN CUSTOMER C
ON S.cust_ID = C.cust_ID
GROUP BY C.zip_code);
RETURN zipWinner;
END;
/
SELECT ZIP_CODE_SALES_WINNER FROM DUAL;