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 3754750
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:35:34+00:00 2026-05-19T09:35:34+00:00

I thought it’ll be easy but i’m really struggling with this. I have a

  • 0

I thought it’ll be easy but i’m really struggling with this.

I have a Table with this schema:
Name, Date, Value

Here’s what I’m trying to achive:

  1. group all rows by ‘Name’
  2. from that group, select the ‘Value’ which it’s ‘Date’ is the
    biggest

The #1 was easily achieved by GroupBy(“Name”,”it”)
but, now what…?
How do i query the grouped results???

Thank you all.

  • 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-19T09:35:35+00:00Added an answer on May 19, 2026 at 9:35 am

    One of the assumptions I’ve made from your question is “Date is the biggest” you mean the latest one for each.

    var data = new List<Data>
                                 {
                                     new Data() {Name = "one3", Date = new DateTime(2001, 11, 11), Value = 7},
                                     new Data() {Name = "one2", Date = new DateTime(2001, 11, 11), Value = 111},
                                     new Data() {Name = "one2", Date = new DateTime(2011, 11, 11), Value = 7},
                                 };
    
    var result = data.GroupBy(x => x.Name).Select(grouping => grouping.OrderByDescending(x => x.Date).Take(1).FirstOrDefault()).ToList();
    

    I’m sure there is probably a better way of doing the linq query but I hope this at least points you in the right direction 🙂

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

Sidebar

Related Questions

I thought this would be really easy but I can't find a simple solution,
I thought this task is easy, but I have no clue how to realize
I thought this would be an easy thing but many hours have gone by
I thought I'd find more about this topic but I didn't. I have to
I thought I would post this here not so much as a question but
I thought this would be pretty academic but its not. I'm trying to traverse
I thought this would be easy, but after scanning many pages Google hasn't come
Thought this would be pretty straight forward, but my value is remaining the same
I thought I had resolved this but I obviously haven't and was hoping someone
I thought this would be fairly simple but it turns out not to work

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.