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

  • Home
  • SEARCH
  • 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 6005015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:20:38+00:00 2026-05-23T01:20:38+00:00

I am familiar with basic queries in SQL, but I need to apply a

  • 0

I am familiar with basic queries in SQL, but I need to apply a filter and I’m not entirely sure how to go about it.

I current have this query:

var query = (from solvedPuzzle in db.SolvedPuzzles
              where solvedPuzzle.UserID == user.ID
              select solvedPuzzle);

And I want to modify the query or filter the results like this pseudocode:

for each pair (a,b) of results
  if a.PuzzleID == b.PuzzleID
     filter out a.NumberOfMoves > b.NumberOfMoves ? a : b

In case that isn’t straightforward enough, I’ll give example results of the filter

Table SolvedPuzzles:
ID   UserID    PuzzleID   NumberOfMoves
1    2         1          5
2    2         1          6   //Will be filtered out
3    2         2          7
4    3         1          8   //Will be filtered out
5    3         1          6
6    4         2          5
7    5         2          4

That is, those two will be filtered out of the results because they are by the same user and the same puzzle, but with a greater number of moves.

  • 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-23T01:20:39+00:00Added an answer on May 23, 2026 at 1:20 am
    var query = (from solvedPuzzle in db.SolvedPuzzles
                  where solvedPuzzle.UserID == user.ID
                  order by NumberOfMoves ascending
                  group solvedPuzzle by solvedPuzzle.PuzzleID into filtered
                  select filtered.First());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm familiar with some of the basics, but what I would like to know
Anyone familiar with specific security issues in the current version of DotNetNuke? (I've already
I'm familiar with the LAMP stack and over the years have successfully deployed a
I'm familiar with SQL Server Indexed Views (or Oracle Materialized Views), we use them
I am writing an internal DSL in Ruby. Currently, the basic structure in this
This is the first time I'm using jqgrid. I have confused in how to
Anyone familiar with error below? When I run my webapp to generate a dynamic
I am familiar with nunit for unit testing of the business layer however I
If you're familiar with the phrase build one to throw away, well, we seem
Being vaguely familiar with the Java world I was googling for a static analysis

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.