Solved

Want to know the best way

Posted on 2006-11-07
4
156 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 25 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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

749 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