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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:49:48+00:00 2026-06-10T11:49:48+00:00

Afternoon, I am trying to return a list of products from my SQL Server

  • 0

Afternoon,

I am trying to return a list of products from my SQL Server 2008 R2 database but I only want to return the results with the latest date.

However the code below seems to return all items, even the ones with an older date. How do I go about getting my results with just the latest date.

var query = (from a in dc.aboProducts
             join t in dc.twProducts on a.sku equals t.sku
             join lp in dc.LowestPrices on a.asin equals lp.productAsin
             select new GetLowestPrices
             {
             productAsin = lp.productAsin,
             sku = t.sku,
             title = t.title,
             twprice = Convert.ToString(t.twPrice),
             lowprice = Convert.ToString(lp.price),
             amzprice = Convert.ToString(lp.tweAmzPrice),
             lastupdated = Convert.ToDateTime(lp.priceDate)
             }).Distinct().OrderBy(ti => ti.title);
return query.ToList();
  • 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-10T11:49:49+00:00Added an answer on June 10, 2026 at 11:49 am

    Try something like this:

    var query =
        from a in dc.aboProducts
        join t in dc.twProducts on a.sku equals t.sku
        join lp in dc.LowestPrices on a.asin equals lp.productAsin
        select new GetLowestPrices
        {
            productAsin = lp.productAsin,
            sku = t.sku,
            title = t.title,
            twprice = Convert.ToString(t.twPrice),
            lowprice = Convert.ToString(lp.price),
            amzprice = Convert.ToString(lp.tweAmzPrice),
            lastupdated = Convert.ToDateTime(lp.priceDate)
        };
    
    var lookup =
        query
            .ToLookup(x => x.sku)
            .Select(x => x.OrderByDescending(y => y.lastupdated).First())
            .OrderBy(x => x.title);
    
    return lookup.ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to figure out how to do this all afternoon, but can't
good afternoon, I am trying to display a list of items in a table
I've been trying to get this to work all afternoon and can't. I want
Good Afternoon, I am trying to get these results into arrays in PHP so
OK, I feel dumb asking this, but I've spent the whole afternoon trying to
Good Afternoon, I am trying to use the composite filter but in vain. While
Afternoon people! I'm trying to implement a list of counties on my Compact Framework
I have been trying to figure this out all afternoon, but have given up
I may be way off base, but I've been trying all afternoon to run
I'm trying to solve this problem all afternoon but with no luck, hopefully someone

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.