Solved

Want to know the best way

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

695 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