-
Help with sql statement
Please looking for help writing a sql statement. I have a table with the following columns
Seller Name
Buyer Name
Buyer Address
Buyer City
Buyer State
Buyer Zip
Sale Date
Unit Number
Complex Name
The table contains all of the past and present owners of condos in different complexes. How can I write a statement which pulls out all of the present owners (Buyer Name, Buyer Address, etc) for a particular complex. I appreciate anyones help.
-
What does Sale Date mean? Date when bought or date when sold?
-
Sale Date is the date the property closed
-
If no sales date, then the property has not sold. If not sold, then the current record where sales date is null should be what you are looking for.
-
There will always be a sales date. The field will never be null.
-
Given the fields you have listed, how would you decide who is a present owner and who isn't if you were looking at the table data?
-
Pull row with most recent sale date for a particular complex.
-
First get the max sale date by complex and unit
Then get all the details you want.
select Buyer_Name, Buyer_Address
from table_name t
,(select complex_name, unit_number, max(sale_date)
from table_name
group by complex_name, unit_number) b
where a.complex_name = b.complex_name
and a.unit_number = b.unit_number
and a.sale_date = b.sale_date
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|