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

Really basic (and probably quite idiotic) question but I'm not familiar with this procedure
I'm new to git; I know the basic commands, but I'm not as familiar
This is a basic Question for all programming languages, But I am much familiar
This must be something very basic. I'm not familiar with the syntax, and this
Ok guys, this is very basic stuff I think. I'm only getting familiar with
This is a really basic ruby gems question. I'm familiar with writing simple ruby
I am not very familiar with OpenGL but I tried to draw a simple
Probably a very basic solution to this, but I can't seem to figure it
I understand this is a basic topic but never done this before starting from
I kind of not familiar with all that JS stuff and everything but today

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.