+ Reply to Thread
Results 1 to 6 of 6

Select Query without duplicates

  1. #1
    Forum Contributor
    Join Date
    08-20-2012
    Location
    Walsall,England
    MS-Off Ver
    Excel 2007
    Posts
    125

    Select Query without duplicates

    Hi,

    I have a table of data with three fields:
    Field 1 = reference number
    Field 2 = year
    Field 3 = grade

    Reference numbers may be duplicated across different years but within each year the reference number will only appear once.

    I want my select query to return each reference number with just the most recent year and corresponding grade i.e. if a reference number appears twice with 2012 and 2013 in the year field, I want the query to return just the 2013 record.

    Is there anyway of doing this with just 1 query?

    Thanks

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2506 Win 11
    Posts
    24,762

    Re: Select Query without duplicates

    Suggest you upload a file with some dummy data for testing and analysis.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor
    Join Date
    08-20-2012
    Location
    Walsall,England
    MS-Off Ver
    Excel 2007
    Posts
    125

    Re: Select Query without duplicates

    Here you go.

    Thanks for the repsonse
    Attached Files Attached Files

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2506 Win 11
    Posts
    24,762

    Re: Select Query without duplicates

    I think that I got what you are looking for with the use of two queries. Look at the attached.

    Alan
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    08-20-2012
    Location
    Walsall,England
    MS-Off Ver
    Excel 2007
    Posts
    125

    Re: Select Query without duplicates

    Hi Alan,

    Thanks for your help, I really appreciate it. Looking at your queries gave me an idea and I have actually managed to combine the elements of your queries into 1!

    Essentially group by ref no, sort ascending examyear (so most recent exam year at the bottom) and last examyear and last grade.

    I'm attaching the final query just in case anybody wants to take a look.

    Thanks again Alan
    Attached Files Attached Files

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2506 Win 11
    Posts
    24,762

    Re: Select Query without duplicates

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. If Duplicates select next value
    By hazzaska in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-28-2012, 10:23 AM
  2. VBA Macro to select duplicates and copy info
    By confesor30 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-19-2011, 04:18 PM
  3. Select duplicates in a column for deleting
    By twaccess in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-24-2010, 12:52 PM
  4. ODBC query duplicates
    By PhoDave in forum Excel General
    Replies: 0
    Last Post: 05-27-2008, 01:36 PM
  5. MS Query-ability to edit select query
    By Robert in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-14-2005, 09:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1