November 20, 2008 at 12:43 am
Existing SQL 2005 Table
-----------------------------
id (int) key
PLZ_FROM (nummeric(4,0))
PLZ_TO (nummeric(4,0))
Territory (VARCHAR2())
id plz_from plz_to territory
2 1000 1110 GD
3 1111 1199 GB
4 1200 1211 GC
5 1212 1214 GB
6 1215 1216 GC
7 1217 1217 GB
8 1218 1226 GC
now i should run a query, as example with the
value 1213 and get back only the column with id 5
other example value 1200 get back column id 4
also the value from the query should be between the values plz_from and plz_to
if you can assist me i would be great..
November 20, 2008 at 2:30 am
Hello,
Would something along these lines get the result that you want:-
Declare @plz numeric(4,0)
Select @plz = 1213
Select
id
From
MyTable
Where
(@plz >= plz_from) And
(@plz <= plz_to)
Regards,
John Marsh
PS: You could also code the Where clause as: (@plz Between plz_from And plz_to)
www.sql.lu
SQL Server Luxembourg User Group
November 24, 2008 at 3:20 am
i had forget to declare the value in my sql statment.
thanks for your help
November 24, 2008 at 3:27 am
Hello again,
Thanks for the update. Glad to hear that it is working now.
Best regards,
John Marsh
www.sql.lu
SQL Server Luxembourg User Group
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply