V4.2
This commit is contained in:
parent
21eaaa6b35
commit
9c88f9b5f7
2 changed files with 16 additions and 4 deletions
|
@ -1,12 +1,15 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION mostValuableClerk(months IN NUMBER) RETURN NUMBER
|
CREATE OR REPLACE FUNCTION mostValuableClerk(months IN NUMBER) RETURN NUMBER
|
||||||
IS
|
IS
|
||||||
startMonat DATE;
|
startMonat DATE;
|
||||||
|
finalclerkid NUMBER;
|
||||||
|
maxanzahlcleanings NUMBER;
|
||||||
BEGIN
|
BEGIN
|
||||||
startMonat := ADD_MONTHS(SYSDATE,-months);
|
startMonat := ADD_MONTHS(SYSDATE,-months);
|
||||||
|
|
||||||
SELECT MAX(Anzahl) FROM
|
SELECT CLERKID, MAX(Anzahl) INTO finalclerkid, maxanzahlcleanings FROM
|
||||||
(
|
(
|
||||||
SELECT DISTINCT CLERKID, COUNT(CLERKID) AS Anzahl
|
SELECT DISTINCT CLERKID, COUNT(CLERKID) AS Anzahl
|
||||||
From
|
From
|
||||||
|
@ -17,7 +20,8 @@ BEGIN
|
||||||
WHERE clpl."date" >= startMonat
|
WHERE clpl."date" >= startMonat
|
||||||
)
|
)
|
||||||
GROUP BY CLERKID
|
GROUP BY CLERKID
|
||||||
);
|
)
|
||||||
|
GROUP BY CLERKID;
|
||||||
|
|
||||||
return null;
|
return finalclerkid;
|
||||||
END;
|
END;
|
|
@ -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 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 BOOKINGROOM VALUES (124980,19724091);
|
||||||
INSERT INTO BOOKINGGUEST VALUES (124980,1274689);
|
INSERT INTO BOOKINGGUEST VALUES (124980,1274689);
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
|
|
||||||
|
DECLARE
|
||||||
|
clerkid NUMBER;
|
||||||
|
BEGIN
|
||||||
|
clerkid := mostValuableClerk(2);
|
||||||
|
DBMS_OUTPUT.PUT_LINE(clerkid);
|
||||||
|
end;
|
Loading…
Add table
Reference in a new issue