dcsimg
Results 1 to 8 of 8

Thread: Help with sql statement

  1. #1
    Join Date
    Nov 2005
    Posts
    3

    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.

  2. #2
    Join Date
    Oct 2005
    Posts
    2,557
    What does Sale Date mean? Date when bought or date when sold?

  3. #3
    Join Date
    Nov 2005
    Posts
    3
    Sale Date is the date the property closed

  4. #4
    Join Date
    Oct 2005
    Posts
    2,557
    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.

  5. #5
    Join Date
    Nov 2005
    Posts
    3
    There will always be a sales date. The field will never be null.

  6. #6
    Join Date
    Dec 2002
    Posts
    5
    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?

  7. #7
    Join Date
    Sep 2002
    Posts
    5,938
    Pull row with most recent sale date for a particular complex.

  8. #8
    Join Date
    Feb 2006
    Posts
    1
    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
  •