Results 1 to 2 of 2
  1. #1
    nmoore5 is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Apr 2014
    Posts
    1

    Query to pull first 4 records greater than zero

    Hello, I'm new to Access. Trying to get something done here at work and haven't found something in the forum yet that gives me my answer. I have many records of well (O&G business) that have several months of production. I am trying to pull the first month of production, first 2 months, 3 months, 4 months, and MAX OIL month. Problem is there are two streams of production. So it has to look at Oil and Gas production and pull the first month that is greater than zero of either Oil or Gas then also pull the corresponding Oil or Gas for that same month or months. I'm also trying to pull the Max oil month for each well and the gas production that corresponds to that month. My query currently has UID | WELL NAME | MONTH | OIL | GASI just need a hint on how to tell it to pull first month greater than zero then the next 2, 3, & 4 months. As well as how to pull the Max from the oil column for each well and the gas for that same month. Thanks for any help and please let me know if I've described this well enough.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,948
    Have you looked at the TOP N qualifier? http://allenbrowne.com/subquery-01.html#TopN

    Quite possibly might require several queries (and/or nested subqueries) to get what you want. Or report with subreports.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Query to pull a percentage of records by user
    By Xarkath in forum Queries
    Replies: 15
    Last Post: 03-21-2014, 11:43 AM
  2. Replies: 2
    Last Post: 05-08-2013, 03:37 AM
  3. Greater than query
    By noobaccess in forum Access
    Replies: 5
    Last Post: 12-05-2012, 09:18 PM
  4. Replies: 5
    Last Post: 06-13-2011, 01:30 PM
  5. Joins to get records greater than
    By thart21 in forum Queries
    Replies: 10
    Last Post: 09-15-2010, 08:45 AM

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