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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:26:39+00:00 2026-05-19T14:26:39+00:00

The following query gives me a barcode, version no of that barcode and an

  • 0

The following query gives me a barcode, version no of that barcode and an appcode. I would need the query to filter out duplicate barcodes and only keep the highest version number of that barcode.

I’ve been thinking along the way of merging the barcode field and the version field and only keep the highest but that seems dirty. Is there a cleaner solution?

select Barcode, MAX(versionNo) vn, Appcode from Mailsort
where Created between '01/26/2011' and '01/27/2011'
group by Barcode, AppCode;

The reason for this query is to get a LINQ statement.This does a count for every appcode regardless of the barcodes or the version at thye moment.

var results = from p in dataContext.GetTable<mailsortEntity>()
              where p.Created > datetime && p.Created < datetime.AddDays(1)
              group p by new { p.AppCode } into g
              select new AppCodeCountEntity
              {
                  AppCode = g.Key.AppCode,
                  Count = g.Count()
              };

Is there a better solution than this LINQ code above?

  • 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-19T14:26:40+00:00Added an answer on May 19, 2026 at 2:26 pm
    var maxQuery = 
     from rh in MailSort
     group rh by rh.BarCode into latest
     select new { BarCode = latest.Key, MaxVersion = latest.Max(l => l.Version) }
    ;
    
    var query = 
     from rh2 in MailSort
     join max in maxQuery on new {rh2.BarCode, Version = rh2.Version } 
      equals new { max.BarCode, Version = max.MaxVersion }
     select new { rh2.BarCode, rh2.Version, rh2.AppCode }
    ;
    
    var barCodes = query.ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following query that gives me an extract (I am putting this
The following LINQ query gives me all files in the specified directory that meet
We have three tables that we would like to query to find out the
The following query gives me a single row because b.id is pinned. I would
How would I recreate the following query in Rails speak so that it returns
I have the following query which gives me the right results. But it's super
I need an sql query to give me the following: All the values in
Using Oracle 11g release 2, the following query gives an ORA-01790: expression must have
While fetching Boolean data from database with hibernate SQL query gives the following error
I need to do a Distinct search in the following query: $listings = $this->Listing->query(SELECT

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.