I'm new here and quite new to SQL and Access. What I have is a table called 'Apartments' that contains a bunch of rows of information. It has Building, Letter, SSN, LeaseDate, MonthlyRent, MoveinCondition and MoveoutCondition. For my class I have to figure out how many times a specific apartment was leased given all the information in the table and display by Building, Letter and NumberLeased.
What I have so far is this:
SELECT Building, Letter, COUNT(*)
FROM Apartments
GROUP BY Building, Letter;
This displays it almost correctly! However there is a catch. There can be multiple tenants on the lease at the same date, but it only counts as one active lease.
So what I did to check was this:
SELECT Building, Letter, LeaseDate, COUNT(*)
FROM Apartments
GROUP BY Building, Letter, LeaseDate;
Now this in fact does group by the building, letter and the lease date and counts the number of leases on the date.
But how do I display it so that it's not counting these duplicates, and add some sort of where or having statement to specify this.
for example: If apartment 1A was leased on 1/1/14 but by 4 tenants and also 1/1/13 by 3 tenants, it should only show the NumberLeased as 2, not 7.