|
-
Feb 2nd, 2011, 11:07 PM
#1
Thread Starter
New Member
SQL Command for ranges
hello everyone.. i apologize if there have been other entries like this but i just had to this last minute thing and microsoft access and vb6 is killing me right now..
so i have a table with a "minimum", "maximum", and "amount" field all set to number data type, double, fixed, and 2 decimal places
in my program i have a textbox that contains a certain value.. once i click the button it is supposed to search the database for where the value on the textbox is in between the minimum and the maximum..
E.G.
minimum maximum amount
0.00 499.00 100.00
500.00 599.00 200.00
600.00 699.00 300.00
text1.text = 555.00
what is the most appropriate sql for this so i get the 200.00 amount needed
since 555.00 is in between 500.00 and 599.00
i am sooo looking forward to an answer.. thank you sooo much in advance to whoever helps out.
-
Feb 2nd, 2011, 11:57 PM
#2
Hyperactive Member
Re: SQL Command for ranges
Dunno
Code:
select Amount
From SomeTable
Where (text1 >= [minimum]) AND (text1 <= [maximum])
If you find information helpful from any member, please take a second and rate their post. Its a nice gesture of your appreciation.
"I have not failed 10,000 times. I have successfully identified 10,000 ways that will not work" Thomas Edison
Do illiterate people get the full effect of Alphabet Soup?
ADO FAQ 2005-2008 Masked Textbox Patch FoxPro Date MZ Tools Great Free Tool
-
Feb 3rd, 2011, 05:56 AM
#3
Re: SQL Command for ranges
Welcome to VBForums 
Thread moved to 'Database Development' forum (the 'VB6' forum is only meant for questions which don't fit in more specific forums)
-
Feb 4th, 2011, 12:43 PM
#4
Re: SQL Command for ranges
Reply in SQL server you could use a case statement. I am not familiar enough with access to know if this syntax will work, but you could give it a try:
Code:
declare @input money; set @input = 555.00
select
case
when @input between 0.00 and 499.00 then 100.00
when @input between 500.00 and 599.00 then 200.00
when @input between 600.00 and 699.00 then 300.00
end
That is the very essence of human beings and our very unique capability to perform complex reasoning and actually use our perception to further our understanding of things. We like to solve problems. -Kleinma
Does your code in post #46 look like my code in #45? No, it doesn't. Therefore, wrong is how it looks. - jmcilhinney
-
Feb 4th, 2011, 01:02 PM
#5
Re: SQL Command for ranges
pifft! No need for the select... the ranges are in a table, right?
Code:
SELECT * FROM tblRanges WHERE @Input BETWEEN MinField and MaxField
Of course replace @Input with what ever means to get your value into it.
-tg
-
Feb 4th, 2011, 01:29 PM
#6
Hyperactive Member
Re: SQL Command for ranges
of course Technome is right. i created a table and tested it
If you find information helpful from any member, please take a second and rate their post. Its a nice gesture of your appreciation.
"I have not failed 10,000 times. I have successfully identified 10,000 ways that will not work" Thomas Edison
Do illiterate people get the full effect of Alphabet Soup?
ADO FAQ 2005-2008 Masked Textbox Patch FoxPro Date MZ Tools Great Free Tool
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|