Add available bookings scripts and results
This commit is contained in:
17
sql/table_is_free.sql
Normal file
17
sql/table_is_free.sql
Normal file
@@ -0,0 +1,17 @@
|
||||
-- available bookings - task 2
|
||||
-- changes:
|
||||
-- changed BookingDate (Reserved) data type from date to datetime, because I assumed that Little Lemon
|
||||
-- allows wants bookings per day and table - a table is considered blocked for 2 hours
|
||||
-- noqa: disable=CP03,LT02,RF03
|
||||
create function TableIsFree(Reserved datetime, TableNumber int)
|
||||
returns boolean
|
||||
deterministic
|
||||
begin
|
||||
return (select not exists (
|
||||
select BookingID
|
||||
from Bookings as B
|
||||
where
|
||||
abs(timestampdiff(second, B.Reserved, Reserved)) < 2 * 60 * 60
|
||||
and B.TableNumber = TableNumber
|
||||
));
|
||||
end
|
||||
Reference in New Issue
Block a user