Requires Free Membership to View
Let's take the active rentals first. You said the Active Rentals table has Start Date and Length. I will assume that Length is in days, and that an "active" rental is one where the Start Date is less than today, and if you added Length days, it would make the duration of the rental go from the Start Date to at least today, or beyond today into the future. The join is the easy part.
select U.RentalAddress
, R.FirstName
, R.LastName
, A.StartDate
, A.Length
from ActiveRentals A
inner
join RentalUnit U
on A.UnitID = U.UnitID
inner
join Rental R
on A.RentalID = R.RentalID
where A.StartDate + Length days
>= current_date
You will probably have to change this syntax to match your particular database. For example, in Microsoft Access, you would need to parenthesize one of the inner joins and change the WHERE condition to
where DATEADD("d",Length,StartDate) >= DATE()
For your second question, units with an ocean view,
select RentalAddress from RentalUnit where OceanView <> 0
For more on Yes/No fields, see Boolean Columns.
This was first published in January 2003

Join the conversationComment
Share
Comments
Results
Contribute to the conversation