Results 1 to 2 of 2
  1. #1
    Karyn is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    13

    Finding predecessors within a table

    I have a table of contracts. These contracts are renewed every year, and therefore many contracts have a version from the previous year, but some are new and have no predecessor. I want to write a query which lists all contracts on the table, together with a reference to any preceding contract with the same customer, or a null if there is none. For example, if the table fields are contract number, customer and year, and the table looks like this:




    Contract Customer Year
    271 Smith 2013
    816 Brown 2013
    101 Jones 2013
    227 Smith 2012
    564 Brown 2012

    I want a query which returns:

    Contract Customer Year Previously
    271 Smith 2013 227
    816 Brown 2013 564
    101 Jones 2013 null
    227 Smith 2012 null
    564 Brown 2012 null



  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    So, build the query (this should give you a starting point)

    SELECT * from yourTable where Customer = "Smith"
    Order By ContractYear Desc

    Year is a reserved word in Access

    Good luck

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Finding Customers (table-1) without Tasks (table-2)
    By fredfortsonsr in forum Queries
    Replies: 3
    Last Post: 02-18-2015, 07:31 PM
  2. Help? One Table, Finding Unmatched
    By geofftke in forum Access
    Replies: 1
    Last Post: 06-07-2013, 11:20 PM
  3. Finding Table Aliases
    By hfile in forum Access
    Replies: 2
    Last Post: 12-26-2011, 02:38 PM
  4. Finding table in form
    By Anne in forum Access
    Replies: 2
    Last Post: 09-22-2011, 01:56 AM
  5. Replies: 2
    Last Post: 06-20-2010, 06:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums