This commit is contained in:
Torben Zwinge 2023-05-12 16:52:59 +02:00
parent 14713af98b
commit 766d928613
2 changed files with 25 additions and 1 deletions

23
SQL/PLSQL.sql Normal file
View file

@ -0,0 +1,23 @@
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;

View file

@ -97,4 +97,5 @@ CREATE TABLE BookingRoom (
PRIMARY KEY(bookingId, roomNumber),
FOREIGN KEY (bookingId) REFERENCES Booking(bookindId),
FOREIGN KEY (roomNumber) REFERENCES Room(roomNumber)
);
);