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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:58:30+00:00 2026-05-28T04:58:30+00:00

How would I query for values near a certain number. I.E. suppose the database

  • 0

How would I query for values near a certain number.

I.E. suppose the database had a table with one column, and int, and that table was populated with every number from 1 – 1000.

How would I write a query so that if I had 100 it would return:
96, 97, 98, 99, 100, 101, 102, 103, 104

  • 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-28T04:58:30+00:00Added an answer on May 28, 2026 at 4:58 am
    int myNumber = 100;
    int myRange = 4;
    
    List<int> resultList = context.MyEntities
        .Where(x => x.MyInt>=myNumber-myRange && x.MyInt<=myNumber+myRange)
        .Select(x => x.MyInt)
        .ToList();
    

    It would give the result in your example but somehow I have the feeling this is not the general solution you are looking for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to get the final SQL query, with parameter values bound (replaced)
I would like to query the mdns database of avahi-daemon through HTTP. Is there
I would like to query the AOT to see if a table name exists
I'm trying to write an SQL query that would search within a CSV (or
I'm trying to write this query, that would calculate the average value of all
I am able to query values without regard to case, but I would like
I used this query to insert all my values into this database: INSERT INTO
I was trying to develop a login program that would work with a database.
I have a query I would like to use that I would like to
I've got a query that I've just found in the database that is failing

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.