Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5931303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:40:31+00:00 2026-05-22T14:40:31+00:00

I have some values which are repeating in my table, I want to select

  • 0

I have some values which are repeating in my table, I want to select only those with the latest/highest date i.e :

ID   Type     Name      Value        Date
--  -------   -----    -------       -------------
1   "FRUIT"  "APPLE"  "Imported"  "2011-03-19 22:08:13"
5   "FRUIT"  "LEMON"  "Imported"  "2011-03-19 22:00:44"
22  "FRUIT"  "PEACH"  "Imported"  "2011-03-20 11:03:13"
31  "FRUIT"  "MELON"  "Imported"  "2011-04-28 18:42:07"
44  "FRUIT"  "PEACH"  "Imported"  "2011-04-12 11:06:11"
98  "FRUIT"  "CHERRY" "Imported"  "2011-03-19 22:46:04"
211 "FRUIT"  "MELON"  "Imported"  "2011-03-19 22:25:24"
217 "VEG"    "SPINACH""Imported"  "2011-03-19 22:25:24"

I’d like to select these :

ID   Type     Name      Value        Date
--  -------   -----    -------       -------------
1   "FRUIT"  "APPLE"  "Imported"  "2011-03-19 22:08:13"
5   "FRUIT"  "LEMON"  "Imported"  "2011-03-19 22:00:44"
31  "FRUIT"  "MELON"  "Imported"  "2011-04-28 18:42:07"
44  "FRUIT"  "PEACH"  "Imported"  "2011-04-12 11:06:11"
98  "FRUIT"  "CHERRY" "Imported"  "2011-03-19 22:46:04"

This is simplified version of what I need, my table has about 20 columns so I want select *, if not I can select one by one.

So I want to select * rows of Type FRUIT but select only those with highest date. Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T14:40:32+00:00Added an answer on May 22, 2026 at 2:40 pm

    This should give you what you want:

    SELECT *
    FROM Table
    INNER JOIN 
    (SELECT Name, MAX(Date) as TopDate
    FROM Table
    WHERE Type = 'FRUIT'
    GROUP BY Name) AS EachItem ON 
        EachItem.TopDate = Table.Date 
        AND EachItem.Name = Table.Name
    

    Basically, it will find the latest date for each type of fruit and then display each fruit with the information for the row (joined on the date and fruit name). Make sure the Date field and Name field are both indexed.

    If you could assume that the item with the highest ID would also be the one with the highest date (typical but not necessarily true in all cases – it depends on your use case), you could do MAX(ID) instead of MAX(Date) and take advantage of just linking by that ID instead of linking by Date and Name.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data table which already has some values, plus it is getting
I have a URL which requires some parameters. The values of those parameters can
The Back Story I have some decimal values which I am displaying as strings
I have a classic ASP application which inserts some values into a word file
I have a large set of values V, some of which are likely to
I have some problem whith such mysql_query INSERT INTO table VALUES ('', CURDATE()-1) why
I have the following method for looping through a table, changint some values in
I have some values in a configuration file (XML file) with some values like
In my C++ application, I have some values that act as codes to represent
I have some configuration values for an asp.net web app. They will be maintained

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.