I have a little problem with finding free rooms in reservation system.
I found some solutions, but they do not seem to work.
My tables:
create table room
(
roomID int not null,
maxPeople numeric(2,0) not null,
beds numeric(2,0) not null,
primary key (roomID)
);
(
reservationID int not null,
clientID int,
roomID int,
startDate date not null,
endDate date not null,
primary key (reservationID)
);
I tried something like this, but that's counting all rooms and totally ignore free rooms.
SELECT Id_pokoju
from rezerwacje
WHERE
(
(SELECT COUNT(ID_pokoju)
from rezerwacje
WHERE "2015-03-10" > Data_konca OR "2015-03-20" < Data_konca)
=
(SELECT COUNT(ID_pokoju)
from rezerwacje
GROUP BY Id_pokoju)
);