?
Solved

Want to know the best way

Posted on 2006-11-07
4
Medium Priority
?
159 Views
Last Modified: 2010-04-30
I have a table and data stored as follows

ID          MIN          MAX                    VALUE
1           0              15                              25
1           16            30                              50
1           31            45                              75
1           46           300                            100

I have a value called x

x = 35

Now I need to find out a way to find that x is basically in which slot. I'm not using SQL statesments in my code. Only storedprocudures.

please let me know the best way it.

Currently what I did was

I have a function and I'm passing the x value to it and there I'm getting those records into a recordset and in a for loop I'm checking the no is exist or not.

I need a better way of doing it
 

         
0
Comment
Question by:ananmanan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 75 total points
ID: 17895812
create function dbo.getslot ( @x int )
returns int
as
  return (select value from yourtable where @x between [MIN] and [MAX])


and you can use it like this:

select * from dbo.getslot(35)
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17895813
... assuming sql server, of course
0
 
LVL 1

Author Comment

by:ananmanan
ID: 17895878
select * from dbo.getslot(35)

What is this "getslot" Is it the table name or what. If its a sp or a view how do I write it

please explain this bit more
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17895895
getslot is the name of the function I suggested you to create.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month8 days, 14 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question