473,472 Members | 1,728 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to look up a range

Give a table with a lower bounds, upper bounds, and targets, I would
like to select on a value and supply the target. For example, think
about marginal tax rates:

AgiLo AgiHi Marginal
00 14600 10%
14601 59400 15%
59401 119950 25%
119951 182800 28%
182801 326450 33%
326451 infinity 35%

A straightforward approach would be
SELECT Marginal from marginalTaxRates where AGI >=AgiLo AND AGI <=
AgiHi

If I have to look up a lot of these Marginal tax rates, is there a more
efficient way to do this? (There might not be; I'm looking for
suggestions.)

Jul 6 '06 #1
5 1126
SELECT Marginal from marginalTaxRates where AGI BETWEEN AgiLo AND AgiHi

Jul 7 '06 #2

Tonkuma wrote:
SELECT Marginal from marginalTaxRates where AGI BETWEEN AgiLo AND AgiHi
Has anyone used LOOKUP for this?

Jul 7 '06 #3

Tonkuma wrote:
SELECT Marginal from marginalTaxRates where AGI BETWEEN AgiLo AND AgiHi
Yeah, BETWEEN is the way to go with that SETUP.

Except "infinity" is not a number, but assuming this is for the real
world, noone will ever have the amaximum capacity of the field.

Just a note. If AgiLo is always (zero or ) one more than AgiHi, AgiHi
is inferred, and unneeded.

SELECT MAX(Marginal) from marginalTaxRates where AGI >=AgiLo

Of course >= is wasteful. :) Instead, it could be a field (Limit) whose
values are 0, then all the AgiHis besides "infinity".

SELECT MAX(Marginal) from marginalTaxRates where AGI Limit

B.

Jul 7 '06 #4
Change the last row to
(326451, NULL, 0.35)

NULL is now your "infinity" symbol. Use between for readability

SELECT marginal
FROM MarginalTaxRates
WHERE agi BETWEEN agi_lo
AND COALESCE (agi_hi, agi);

Jul 8 '06 #5

Brian Tkatch wrote:
SELECT MAX(Marginal) from marginalTaxRates where AGI >=AgiLo
Yes, this would work if we always have a progressive system, where
Marginal rates are increasing. Unfortunately, I cannot make that
assumption with the real data.

You do have an excellent observation about the problem of
non-continguous data. After all, it is possible to have a
dollars-and-cents AGI that falls between the cracks.

Jul 12 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Xah Lee | last post by:
Today we'll be writing a function called Range. The Perl documentation is as follows. Perl & Python & Java Solutions will be posted in 48 hours. This is Perl-Python a-day. See...
1
by: Thomas | last post by:
Hi dudes, I have a range object for text (not the one in the IE, the one for Mozilla). Now I have a function to reduce/move the range in the text to the LEFT, e.g.:...
5
by: Chris | last post by:
Hey all. Anyone who is familiar with Python programming knows that you can have code like this: list = This code puts all the items processed by the for loop in a list plus 1. Is there a way...
29
by: Steve R. Hastings | last post by:
When you compile the expression for i in range(1000): pass does Python make an iterator for range(), and then generate the values on the fly? Or does Python actually allocate the list and...
3
by: toton | last post by:
Hi, I want ro iterate over a few container class within a range specified, instead of begin & end. How to construct a range class, which takes start & end, and iteration is available within that...
85
by: Russ | last post by:
Every Python programmer gets this message occasionally: IndexError: list index out of range The message tells you where the error occurred, but it doesn't tell you what the range and the...
11
by: Peted | last post by:
Im using c# 2005 express edition Ive pretty much finished an winforms application and i need to significantly improve the visual appeal of the interface. Im totaly stuck on this and cant seem...
6
by: grego9 | last post by:
I am trying to return a value from an access database by looking up a value in excel. This is the code I have copied from another source - but I cannot get it to work - I keep getting a run time...
0
by: iain654 | last post by:
I have finally worked out how to automatically send a range of cells in the body of an email using Outlook but it is very clumsy and I have to build up the email using the limit of line...
2
by: alireza6485 | last post by:
Hi, Could you please rewrite the program for me?I tried my best and the program still does not do what it has to do. I have to write a code that generates random speed and distance .it ask the...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.