This commit is contained in:
Torben Zwinge 2023-05-12 17:09:20 +02:00
parent 21eaaa6b35
commit 9c88f9b5f7
2 changed files with 16 additions and 4 deletions

View file

@ -1,12 +1,15 @@
CREATE OR REPLACE FUNCTION mostValuableClerk(months IN NUMBER) RETURN NUMBER
IS
startMonat DATE;
finalclerkid NUMBER;
maxanzahlcleanings NUMBER;
BEGIN
startMonat := ADD_MONTHS(SYSDATE,-months);
SELECT MAX(Anzahl) FROM
SELECT CLERKID, MAX(Anzahl) INTO finalclerkid, maxanzahlcleanings FROM
(
SELECT DISTINCT CLERKID, COUNT(CLERKID) AS Anzahl
From
@ -17,7 +20,8 @@ BEGIN
WHERE clpl."date" >= startMonat
)
GROUP BY CLERKID
);
)
GROUP BY CLERKID;
return null;
return finalclerkid;
END;

View file

@ -9,4 +9,12 @@ INSERT INTO CLEANINGCLERK VALUES (1274689,124890);
INSERT INTO BOOKING VALUES (124980,TO_DATE('2023-05-01', 'YYYY-MM-DD'),TO_DATE('2023-05-02', 'YYYY-MM-DD'),700,'No Pension',0,1274689);
INSERT INTO BOOKINGROOM VALUES (124980,19724091);
INSERT INTO BOOKINGGUEST VALUES (124980,1274689);
commit;
commit;
DECLARE
clerkid NUMBER;
BEGIN
clerkid := mostValuableClerk(2);
DBMS_OUTPUT.PUT_LINE(clerkid);
end;