Click here to Skip to main content
15,896,478 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a table as follows:

Scheme Id     RsStart      RsEnd            ProductId        ProductQty
1               0           200                 2                10
1              200          400                 6                15
1              400          500                 4                5


I want to select all records for which a given amount is between RsStart and RsEnd. For example given amount = 225 I want to select second row.

Thanks in advance.
Posted
Updated 2-May-10 1:01am
v2

1 solution

This is a very simple query, I suggest you should read a book on SQL.

You can try this:
SELECT [Scheme Id], RsStart, RsEnd, ProductId, ProductQty FROM tablename WHERE RsStart>='X' AND RsEnd<='X';

Where X is the given amount.

------------------------------------------------------------------------------
EDITED
Using select * is bad practice, so I've amended the script to explicitly name the columns. Apart from that, this snippet was good to go.
------------------------------------------------------------------------------
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900