Results 1 to 4 of 4
  1. #1
    AccessSHELL is offline Advanced Beginner
    Windows 10 Access 2003
    Join Date
    Jul 2020
    Location
    U.S.
    Posts
    58

    Question Having a difficult time writing a query


    In Access 2003 on WIN10. I have a table with the following fields: ItemNbr, RecNbr, Desc. There are more fields, but not important for discussion. Each ItemNbr can have several RecNbr's. I need a query the displays one record for each unique ItemNbr. Other fields in results need to be Desc and MAX recNbr for the ItemNbr. The Desc field should contain the Desc from associated recNbr 1.

    Thanks

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    Q1: pull MAX(RecNum), itmNum

    then Q2:
    use Q1 to pull the full record by joining on RecNum.
    select table.* from Q1,table where table.recNum=Q1.recNum

  3. #3
    AccessSHELL is offline Advanced Beginner
    Windows 10 Access 2003
    Join Date
    Jul 2020
    Location
    U.S.
    Posts
    58
    I wrote Q1 as:
    "SELECT table.itmNbr, Max(table.RecordNum) AS MaxRecNbrFROM table
    GROUP BY table.itmNbr
    ORDER BY table.itmNbr "
    I got what I expected. That worked great.

    Can you expand Q2 for me?

  4. #4
    AccessSHELL is offline Advanced Beginner
    Windows 10 Access 2003
    Join Date
    Jul 2020
    Location
    U.S.
    Posts
    58
    I got it. It took a while to fully understand Q2.

    Thanks

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

Similar Threads

  1. Replies: 4
    Last Post: 07-05-2013, 06:54 PM
  2. Difficult Query!
    By pastormcnabb in forum Queries
    Replies: 2
    Last Post: 04-09-2013, 09:40 PM
  3. difficult query
    By methis in forum Queries
    Replies: 2
    Last Post: 03-18-2013, 02:36 PM
  4. Replies: 7
    Last Post: 05-31-2011, 11:51 AM
  5. Replies: 2
    Last Post: 07-14-2010, 06:10 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