diff --git a/SQL/PLSQL.sql b/SQL/PLSQL.sql new file mode 100644 index 0000000..7253299 --- /dev/null +++ b/SQL/PLSQL.sql @@ -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; \ No newline at end of file diff --git a/SQL/Schema.sql b/SQL/Schema.sql index 40414ef..fd089db 100644 --- a/SQL/Schema.sql +++ b/SQL/Schema.sql @@ -97,4 +97,5 @@ CREATE TABLE BookingRoom ( PRIMARY KEY(bookingId, roomNumber), FOREIGN KEY (bookingId) REFERENCES Booking(bookindId), FOREIGN KEY (roomNumber) REFERENCES Room(roomNumber) -); \ No newline at end of file +); +