+ Reply to Thread
Results 1 to 12 of 12

criteria in Select query to show last 4 entries

  1. #1
    Forum Contributor
    Join Date
    12-20-2012
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    171

    criteria in Select query to show last 4 entries

    hi all

    i have query with many rocords...what i want to to do is to put criteria to show only last 4 date entries (last 4 recent date entries)

    for example i have
    1 aug 17
    5 aug 17
    13 aug 17
    15 aug 17
    20 aug 17
    23 aug 17

    and the criteria to show only:
    13 aug 17
    15 aug 17
    20 aug 17
    23 aug 17

    please help either by criteria or filter
    thanks

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: criteria in Select query to show last 4 entries

    Hi boss,

    I think you are looking for the large function. See the attached. If you have a columns of names and dates next to them and want the last four dates per name, that is a different question and answer.

    Large Function to show most current dates.xlsx
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Contributor
    Join Date
    12-20-2012
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    171

    Re: criteria in Select query to show last 4 entries

    Hi Marvin,

    thank you for your quick response, please see the attached file, the data under date column is always unique, i need the criteria that to show only last 4 date entries (last 4 recent date entries).

    the highlighted rows will be shown as a result.

    thanks again.

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: criteria in Select query to show last 4 entries

    Which database are you using?

    Possibly:
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    12-20-2012
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    171

    Re: criteria in Select query to show last 4 entries

    Hi Kyle,

    i didnt understand where to put the code and how to change it to match my columns names, by the way, please find attached screen shot where under "Progress_Date_: Date_"
    should be the criteria i am asking for.

    i put the following criteria
    Between Date() And DateAdd("m",-1,Date())

    which will show us all records in last 30 days, it is useful but i need the last 4 date entries (last 4 recent date entries).

    thanks
    Attached Images Attached Images

  6. #6
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: criteria in Select query to show last 4 entries

    Go to SQL view and post the SQL please

  7. #7
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: criteria in Select query to show last 4 entries

    If it helps, this sql statement would select the 4 most recent dates from [Table1], where the date column in question is [dt]:

    Please Login or Register  to view this content.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  8. #8
    Forum Contributor
    Join Date
    12-20-2012
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    171

    Re: criteria in Select query to show last 4 entries

    this is the SQL

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    12-20-2012
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    171

    Re: criteria in Select query to show last 4 entries

    any help plz?

  10. #10
    Forum Contributor
    Join Date
    12-20-2012
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    171

    Re: criteria in Select query to show last 4 entries


  11. #11
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: criteria in Select query to show last 4 entries

    Hey boss,

    Build your criteria like you show above for the last 30 days, then switch the criteria view to the SQL view. Put "Top 4" after the select and then do the search using the "!" Icon. Does this give what you want?

  12. #12
    Forum Contributor
    Join Date
    12-20-2012
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    171

    Re: criteria in Select query to show last 4 entries

    Dear All,

    I Solved it by creating another query.

    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. [SOLVED] Run a 2nd query to show what is NOT displayed in the f1st query
    By MissDB in forum Access Tables & Databases
    Replies: 2
    Last Post: 10-05-2016, 07:43 AM
  2. Dependable Dropdown when I select Criteria the data show in column B
    By AaruJaan in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-29-2016, 11:20 AM
  3. select query where one table has not entries, but still want other data
    By jillp in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-13-2015, 08:02 AM
  4. Replies: 2
    Last Post: 04-10-2014, 09:36 AM
  5. Replies: 10
    Last Post: 03-04-2013, 09:02 AM
  6. Query criteria based of other query data
    By jik_ff in forum Access Tables & Databases
    Replies: 6
    Last Post: 03-12-2012, 05:26 PM
  7. [SOLVED] 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

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