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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:51:28+00:00 2026-06-04T23:51:28+00:00

I have a data with multiple lines that are similar. They are latest results

  • 0

I have a data with multiple lines that are similar. They are latest results in games and for example if there are 3 goals that are scored in the game, that would mean 3 lines.

enter image description here

I want to distinct one game one line. But the distinct lines have to be the newest (firstOrDefault?)

I do want to show both status=Confirmed and status=Open but obviously i don´t want to show the same game both “Confirmed” and “Open”

So i want to group by both columns “Hometeam” and “outteam”. But for same game I would get 3 lines if there were 3 goals but i want the “newest line”.

Could someone help me with this?

  • 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-06-04T23:51:30+00:00Added an answer on June 4, 2026 at 11:51 pm

    You could try something like this:

    data.GroupBy(d => new { Hometeam = d.Hometeam, Outteam = d.Outteam })
        .Select(g => g.OrderBy(d => d.Status)
                      .ThenByDescending(d => d.GoalsHometeams + d.GoalsOutteams)
                      .First())
    
    1. Groups by the team combinations
    2. For each group, finds the entry with the newest status (Confirmed comes before Open in alphabetical order)
    3. If multiple with same status (i.e., multiple Open), finds entry with highest combined score.
    4. Grabs the first result (which should be newest) per group.

    Demo: http://ideone.com/vlCtw

    Sample Result:

    Current game status results:
    Confirmed, Fylkir, Valur, 3, 1
    Confirmed, Selfoss, Grindavik, 3, 3
    Confirmed, Keflavik, IBV, 1, 0
    Confirmed, Stjarnan, IA, 1, 1
    Confirmed, Breioablik, Fram, 0, 2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file that contains multiple lines of data, e.g: dfscmd /map \SERVER\PATH\AREA\testuser
I have multiple data items, each with a value V that has multiple tags
I have multiple data entries that contain the following information: id_number name1 date name2
I have a data frame consisting of results from multiple runs of an experiment,
I have a query that transfers data from multiple slave tables into a single
I have a cube that I have build that has data across multiple servers.
Will Oracle flatten multiple between clauses if they have overlapping data? In my application,
I have written an SSIS package that essentially takes data from multiple sources and
i have a stored procedure that has to retrieve data from multiple tables something
I have a .txt file that I created with multiple lines. When I run

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.