Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 3rd, 2005, 01:54 AM
Authorized User
 
Join Date: Oct 2004
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default look up table like in excel?

hi guys

i have my tax table,sss table
right now im using
case ..
sample code is
select case taxcode
           when 'z' then
                   case when grosspay between 417 and 1250 then grosspay0417*10+20.83
....

how can i replace this like lookup in exccl ,,let say that i will creat a tble then i will have to lookup this table to find the grosspay..
 hope u can help me..

tnx

 
Old October 3rd, 2005, 10:59 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 385
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Not sure I follow your question but simply link to the table. My understanding is thats all excel is doing. Give us some sample rows in the table you want to lookup if you want someone to give you the sql code for it.

 
Old October 3rd, 2005, 07:17 PM
Authorized User
 
Join Date: Oct 2004
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i want to make a table (if possble) for ss..tax..

grosspay er
between 1000-12499.99 60.70
1250-1749.99 91
1750-2249.99 121.30
.
.
.
right now m using case statement
like select case when grosspay between 1250-1749.99 then 60.70
......

its very hard to maintain this case when i need to modify it.
can i create a table then look up its value to get the grosspay
hope this is clear
tnx for helping :)

 
Old October 4th, 2005, 04:53 PM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 385
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok then a table is just what you want with values something like this below:

LowRange HighRange TargetValue
1000 1249.99 60.70
1250 1749.99 91.00
1750 2249.99 121.30

Then you want a SQL statement something like
select TargetValue where SourceValue >=LowRange and SourceValue <= HighRange
But you need to be sure you don't have overlaping values between the LowRange and the HighRange.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting Table to Excel Sheets ayazhoda Access VBA 11 April 5th, 2007 07:25 AM
Importing from Excel to Access table DeborahP Excel VBA 3 April 3rd, 2007 03:21 AM
Displaying Excel data in a table badgolfer ASP.NET 1.0 and 1.1 Basics 6 January 6th, 2006 04:25 AM
Export Table from Access to Excel aramchan Access VBA 2 July 12th, 2004 03:20 PM
Writing to an Oracle table from Excel emad100 Excel VBA 0 October 29th, 2003 10:24 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.