23 lines
No EOL
514 B
SQL
23 lines
No EOL
514 B
SQL
|
|
|
|
CREATE OR REPLACE FUNCTION mostValuableClerk(months IN NUMBER) RETURN NUMBER
|
|
IS
|
|
startMonat DATE;
|
|
BEGIN
|
|
startMonat := ADD_MONTHS(SYSDATE,-months);
|
|
|
|
SELECT MAX(Anzahl) FROM
|
|
(
|
|
SELECT DISTINCT CLERKID, COUNT(CLERKID) AS Anzahl
|
|
From
|
|
(
|
|
SELECT clcl.CLERKID
|
|
FROM CLEANINGCLERK clcl
|
|
INNER JOIN CLEANINGPLAN clpl ON clcl.CLEANINGPLANID = clpl.CLEANINGPLANID
|
|
WHERE clpl."date" >= startMonat
|
|
)
|
|
GROUP BY CLERKID
|
|
);
|
|
|
|
return null;
|
|
END; |