Results 1 to 4 of 4
  1. #1
    Siiig is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2013
    Posts
    30

    Outputting the first line in a set of results.

    Currently I have a set of queries that break down to something like this...



    Number Item Date
    0000004 001 9/10/2013
    0000004 001 6/14/2013
    0000004 001 5/19/2013
    0000004 001 2/5/2013
    0000004 001 1/19/2013
    0000004 001 1/1/2013

    What I'd like to do, is take this long query, and only take the first result of the returned values, I.E.:

    Number BillNumber RequiredDate
    0000004 001 9/10/2013

    (Note: There are more results in the query, I'm just condensing it).

    Something like this ALMOST works...

    SELECT DISTINCT dates.Number
    FROM dates;

    The above will give me a unique list from the "Number" column, but I can't manage to get the data to it's right back into place.

    Was hoping you guys could help me out!

  2. #2
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    Try the TOP function in your query.

    Like SELECT TOP 1

    Look into this link.

    http://www.w3schools.com/sql/default.asp


    Dale

  3. #3
    Siiig is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2013
    Posts
    30
    Quote Originally Posted by rzw0wr View Post
    Try the TOP function in your query.

    Like SELECT TOP 1

    Look into this link.

    http://www.w3schools.com/sql/default.asp


    Dale
    Hey Dale,

    Thank's a bunch for the response. Specifically "SELECT TOP 1" gave me a new version of the results, but not quite what I'm looking for. That actually resulted in a full set of results. Let me give you a better example of the data it's pulling...

    WorkOrder BillNumber RequiredDate
    0000007 1 7/4/2013
    0000007 1 6/15/2013
    0000007 1 5/27/2013
    0000007 1 5/27/2013
    0000007 1 5/14/2013
    0000008 2 6/15/2013
    0000008 2 7/4/2013
    0000008 2 5/14/2013
    0000008 2 5/27/2013
    0000009 3 5/14/2013
    0000009 3 2/26/2013
    0000009 3 6/15/2013
    0000009 3 5/27/2013
    0000009 3 4/1/2013

    Using "Top" will return all the "0000007" records. The only other thing I can think of would be to check the previous records "WorkOrder" table, and then do a looping "not equal to" constraint. Problem being I have no idea how to do that of coarse.

  4. #4
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    Then you did not use TOP correctly.
    TOP number will only return the Top number specified of records.

    If you use Top 10, it will return 10 records if 10 are there.

    Have you been to the site I gave you?

    Dale

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

Similar Threads

  1. Line by Line Transactional Data Queries
    By defaultuser909 in forum Queries
    Replies: 7
    Last Post: 07-18-2012, 10:00 AM
  2. Outputting proper grammar . . .
    By timmygrover in forum Queries
    Replies: 2
    Last Post: 03-28-2012, 03:09 PM
  3. Replies: 37
    Last Post: 01-11-2012, 02:16 AM
  4. Replies: 2
    Last Post: 08-05-2011, 01:24 PM
  5. Replies: 7
    Last Post: 04-11-2011, 03:58 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